Check unbound combo content

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.

.......
 
D

Douglas J. Steele

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top