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.

........
 
S

Steve Easton

Aw shucks. I was going to answer it.

You don't need a sub.

Simply check the status of: Me.cmbCompany.Value and Me.cmbProduct.Value
after the end of the routine that loads the combo boxes.

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

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

is all you need
Also if you use in line If Then you don't need End If

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

will work

And also, you don't need to specify Me since it's obvious the code is in the form that contains the combo boxes.


If cmbCompany.Value = Null Then cmdMonthEnd.Enabled = False
If cmbProduct.Value = Null Then cmdMonthEnd.Enabled = False

is all you actually need because Me is implied

--
Steve Easton
Microsoft MVP FrontPage
FP Cleaner
http://www.95isalive.com/fixes/fpclean.htm
Hit Me FP
http://www.95isalive.com/fixes/HitMeFP.htm
 

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

Top