Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling command buttons when list box contains no records 1

Status
Not open for further replies.

awhitsel

Programmer
Feb 22, 2001
80
US
I want to be able to either disable or make invisible two command buttons on my form whenever there are no records showing in a list box.

I believe that I had brought up this problem once before, but I getting back around to working on this part again.
 
The VBA would be

If ListBoxName.ListCount = 0 Then
CommandButton.Enabled = True
Else
CommandButton.Enabled = False
End If

Where you put this will depend on how you are determining if there is anything in the listbox.

ljprodev@yahoo.com
ProDev
MS Access Applications
 
cmdButton.Enabled = lstListBox.ListCount > 0

If Column Heads of lstListBox is selected Yes then:

cmdButton.Enabled = lstListBox.ListCount > 1

Aivars


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top