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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enable/Disable Command Button 2

Status
Not open for further replies.

jadams0173

Technical User
Joined
Feb 18, 2005
Messages
1,210
Hey all! I want to check and see if data is present in a table. If there is data in that specific field then I want to enable a command button in a form. If not I want to disable the command button. This should be checked each time the user moves to a new reocrd. Thanks in advance!
 
Try something like this in the On Current of your form:

Private Sub Form_Current()
If IsNull(Me!YOURFIELDNAME) Then
Me!YOURBUTTONNAME.Enabled = False
Else
Me!YOURBUTTONNAME.Enabled = True
End If
End Sub

HTH
 
Hey Krispi. Thanks for replying. The only catch is the data is not displayed in a form, just stored in a table. What I'm trying to do is if the record in the table has a picture stored on the network then I let the user view the picture. For now I'm manually putting it in the table. In the future they will all have a picture, I'm just trying to prevent someone thinking that the pic isn't displaying when it really doesn't exist. I'm guessing based on you post that maybe I should make a hidden text box to reference to see if it has data in it? Thanks again.
 
Hey again Krispi. I made the hidden txtbox and checked it for Null and the code works! Thanks for you help!
 
The one-liner version of krispi's code:
Me!YOURBUTTONNAME.Enabled = Not (IsNull(Me!YOURFIELDNAME))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top