richard luft
Registered User.
- Local time
- Today, 05:54
- Joined
- Jun 4, 2004
- Messages
- 63
I'd like to set a value for control 'units' on 'form2' ans am having difficulty with the following macro.
Macro action is: SetValue
Item: [Forms]![Form2]![Units]
Expression: ElapsedDays([Units])
Macro is run on 'afterupdate' event of contol on form named 'Date_To'.
Function "ElapsedDays" is coded as follows:
Function ElapsedDays(Units) As Integer
If Not IsNull([Forms]![Form2]![Date_To]) Then
Units = DateDiff("d", (Forms![Form2]![Date_From]), (Forms![Form2]![Date_To])) + 1
ElseIf IsNull([Forms]![Form2]![Date_To]) Then
Units = 1
End If
End Function
The problem is that, although Function Elapseddays always gives the correct # of elapsed days, it is not setting the value of control 'units'. In fact, although the default value of 'units' = 1, it is consistently being set to 0 instead of the correct value.
Any solutions for this problem will be appreciated
TIA, Richard
Macro action is: SetValue
Item: [Forms]![Form2]![Units]
Expression: ElapsedDays([Units])
Macro is run on 'afterupdate' event of contol on form named 'Date_To'.
Function "ElapsedDays" is coded as follows:
Function ElapsedDays(Units) As Integer
If Not IsNull([Forms]![Form2]![Date_To]) Then
Units = DateDiff("d", (Forms![Form2]![Date_From]), (Forms![Form2]![Date_To])) + 1
ElseIf IsNull([Forms]![Form2]![Date_To]) Then
Units = 1
End If
End Function
The problem is that, although Function Elapseddays always gives the correct # of elapsed days, it is not setting the value of control 'units'. In fact, although the default value of 'units' = 1, it is consistently being set to 0 instead of the correct value.
Any solutions for this problem will be appreciated
TIA, Richard
Last edited: