expression in property box

tubar

Registered User.
Local time
Today, 13:38
Joined
Jul 13, 2006
Messages
190
i have a combo box and when the user checks it i want todays date to appear in another field. i wrote the following expression in the "on click" field of the property for the combo box

iif([complete]=true,[date completed]=date())

this doesnt work can you tell me why
 
The sytax for the IIF function is this:

iif(expression, true, false)

You dont have a false section of the IIF statement.

btw...from the VBA Help file...
Returns one of two parts, depending on the evaluation of an expression.
Syntax
IIf(expr, truepart, falsepart)
The IIf function syntax has these named arguments:
 
That doesn't go in the property of the event, you should actually be putting it in the VBA window instead. You either have to select an existing macro or select [Event Procedure] to use VBA code in the VBA Window. You can't use the IIF by itself in the spot you tried.
 
Private Sub COMPLETE_AfterUpdate()
If Me.COMPLETE Then
Me.[DATE_ELEC_LUMA_FIX] = Date
Else
Me.[DATE_ELEC_LUMA_FIX] = Null

End If


i tried this and its giving me errors
 
You need to put End Sub at the end of the the after update event.

Code:
Private Sub COMPLETE_AfterUpdate()
If Me.COMPLETE Then
Me.[DATE_ELEC_LUMA_FIX] = Date
Else
Me.[DATE_ELEC_LUMA_FIX] = Null

End If

[COLOR=red]End Sub[/COLOR]
[COLOR=black]
[/COLOR]
 
compile error:
expected end sub

So as Scooterbug said:

Code:
Private Sub COMPLETE_AfterUpdate()
If Me.COMPLETE Then
Me.[DATE_ELEC_LUMA_FIX] = Date
Else
Me.[DATE_ELEC_LUMA_FIX] = Null

End If
[COLOR="Red"]End Sub[/COLOR]
 
i have a combo box and when the user checks it i want todays date to appear in another field. i wrote the following expression in the "on click" field of the property for the combo box

iif([complete]=true,[date completed]=date())

this doesnt work can you tell me why

To begin with, you speak of a combobox and then you talk about "checking" it and its value being "true." Sounds like a checkbox to me, and I assume that's what it actually is.

Try changing your code to
Code:
Private Sub COMPLETE_AfterUpdate()
If Me.COMPLETE Then
 Me.DATE_ELEC_LUMA_FIX = Date
Else
 Me.DATE_ELEC_LUMA_FIX = Null
End If
End Sub

omitting the brackets around the control name abd make sure you actually have End Sub at the end. And as Bob said, you should always include error messages if you're experiencing them.
 

Users who are viewing this thread

Back
Top Bottom