NZ problem in a form using VBA (1 Viewer)

bessej43

Registered User.
Local time
Today, 18:30
Joined
Jun 12, 2002
Messages
22
I have a form that has a field called "SumOfTotal Days", it is populated by counting the number of days taken as leave. It rolls it up to one number. If a person does not take any leave then I want it to put a zero "0" in the SumOfTotal Days box. It is working fine when there is a value but not there is none.

The Form name is [Use for Lv Menu]
The populated field is [SumOfTotal Days]

Here is what I wrote but it is coming back with an error as follows; "You entered an expression that has no value".

Should I put the NZ statement in the query?

Private Sub Form_Open(Cancel As Integer)
Dim frm As Form, ctl As Control
Dim SumOfTotalDays As Single

' Return Form object variable pointing to the form.
Set frm = Forms![Use for LV Menu]
' Return Control object variable pointing to SumOfTotal Days.
Set ctl = frm![SumOfTotal Days]
' Choose result based on value of control.
varResult = Nz([SumOfTotal Days], "")
' Display result.
Me.[Use for LV Menu] = [SumOfTotal Days]
Me.Recordset.Edit
Me.Recordset![Use for LV Menu] = [SumOfTotal Days]
Me.Recordset.Update

Any help would be greatly appreicated.
 

bessej43

Registered User.
Local time
Today, 18:30
Joined
Jun 12, 2002
Messages
22
Sorry I put this in the wrong forum

It should have went to the VBA forum, please review the VBA forum.
 

Users who are viewing this thread

Top Bottom