Programming to Insert Current Date when Combo Box Status Changed to Specific Item (1 Viewer)

themurph2000

Fat, drunk, and stupid
Local time
Today, 15:48
Joined
Sep 24, 2007
Messages
181
Hey folks. I'm working on a form that, when a combo box is set to a certain status (from "In Process" to "Ready"), another field in the underlying table should be populated with the current date. Now this can be done in a macro easily if you only needed to record when the combo box's selection is changed (do a SetValue and tie it to the AfterUpdate property). However, I was trying to do some VBA to do this, since it has to be a specific statement in the combo box that triggers it.

PHP:
Private Sub Project_Status_AfterUpdate()
If Project_Status = "Ready" Then Me![actualDate] = Date()
End If
End Sub

For whatever reason, I get a compiling error telling me that there's an End If statement without a block If statement.

Any thoughts? Thanks.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:48
Joined
Aug 30, 2003
Messages
36,125
Drop everything after "Then" to a new line (or get rid of the End If).
 

themurph2000

Fat, drunk, and stupid
Local time
Today, 15:48
Joined
Sep 24, 2007
Messages
181
Drop everything after "Then" to a new line (or get rid of the End If).

It seems kind of anal for the VBA compiler to flag me for not having the stuff on two lines, but that was the fix. Thanks.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:48
Joined
Aug 30, 2003
Messages
36,125
You mixed the one-line and block formats. Having it on one line is fine, but that leaves the End If "twisting in the wind". You could also have gotten rid of that to eliminate the error.
 

Users who are viewing this thread

Top Bottom