Change event help

  • Thread starter Thread starter kia.martin
  • Start date Start date
K

kia.martin

I'm trying to get a message box to show when the user makes changes to
the phase combo box of my form. I put break points in the code and it
goes into it but nothing displays. I just want the box to pop up when
the other combo boxes are empty but it doesnt seem to be happening. Any
help please?

Private Sub CboPhase_Change()
'********
'* Combo Box validation
'* 8/1/06 kmartin
'********

If CboPhase = 0 Then
DoCmd.Requery
Else
If CboJob = " " Then
MsgBox "Job Number must be entered"
CboJob.SetFocus
DoCmd.Requery
End If
If CboCat = " " Then
MsgBox "Category must be entered"
CboCat.SetFocus
DoCmd.Requery
End If
End If

dateupdated = ReturnCurrentDate
changeuser = ReturnCurrentUser
End Sub
 
First, the Change event is not the correct place to put this code. The
Change event fires after each keystroke. You really want to use the After
Update event.
Second, checking for " " is probably not going to work unless you have
initialized your combo to that value. A combo with no selection make will
return Null. In the event that it could be an empty string or a single space
(neither of which is likely), you can use the following test.

Instead of
If CboJob = " " Then
Try
If Len(Trim(Nz(CboJob),"")) = 0 Then
 
I got a compile error of wrong number of arguments or invalid property
assignment when I used

If Len(Trim(Nz(CboJob),"")) = 0 Then
 
My bad, syntax is wrong, my apologies.
Should be:

If Len(Trim(Nz(CboJob,""))) = 0 Then
 
Back
Top