Check unbound combo content

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Groupies

I have an unbound form with 2 unbound combo boxes. The first combo lists
companies, the second lists products. I also have a button to print a report
based on the choices of these combox.

I am trying to keep the button disabled until both combos are filled in. I
have tried a couple of things but my code is being 'ignored' and the button
is always available.

Here is my current code:

Private Sub Form_Current()

If Me.cmbCompany.Value = Null Then
Me.cmdMonthEnd.Enabled = False
End If

If Me.cmbProduct.Value = Null Then
Me.cmdMonthEnd.Enabled = False
End If

End Sub

Can somebody please help me out with why this is being completely ignored.

.......
 
You cannot check if a value is Null using =.

Private Sub Form_Current()

If IsNull(Me.cmbCompany.Value) Then
Me.cmdMonthEnd.Enabled = False
End If

If IsNull(Me.cmbProduct.Value) Then
Me.cmdMonthEnd.Enabled = False
End If

End Sub

Of course, you're never re-enabling the controls, so you may want something
a little more than that!
 
Back
Top