Null values in calculations.

dwcrockford

New Member
Joined
Sep 1, 2015
Messages
27
OK.... there's a process to this one and various objects.

tblHours - has days of the week (numeric) default value set to "0"
tbhHours subform - used in another form, based from the above table
frmTimesheet - main user form which has the above subform on it as well as additional calculated form objects.

On the main user form (frmTimesheet), some days will not have any hours entered, so they are left at "0" by default (at least this is what is displayed.

Within the form, there are calculations based on the tblHours subform. All the calculations work just fine - IF there are numbers entered or you manually enter "0". If a entry is skipped on the subform, the subsequent calculations leave those calculation object empty (no "0" - just a blank box).

This affects further calculations as well leaving more blank form objects.

I know somewhere, a "null" statement needs to be entered (isnull=0 or similar code that is correct), but where along the way should this statement be entered - somewhere on the source table (Hours), subform or main user form (and what is the correct code to use?)

D
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Not sure if I completely get the drift, but it sounds like the default 0 is set at the table level. If you do not create a record, the default is not saved as a record.
If a entry is skipped on the subform
That's not how it works. Only when you create a record by entering data in other fields but don't supply a value for those with defaults do the defaults kick in.

If this is a variable, it's a name you should not use. If it's an expression you created, it will never be true.

I can't tell you exactly where to put an expression without knowing what's behind the form/subform and the relationships, but to save a 0, your code or calculated control (unbound, because bound controls cannot contain expressions) can use the IIF expression IIF(IsNull(something),0,Null) or the NZ function NZ(something,0). If nulls are not allowed in the table, you can use empty strings "" as long as the data type is string NZ(something,"")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,832
Messages
6,162,255
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top