Change button properties based on criteria

mhk

Registered User.
Local time
Yesterday, 22:14
Joined
Aug 5, 2008
Messages
14
I'm not sure if this is even possible in Access. But I would like to change the properties of buttons based on if data is entered in specific fields of the tables the buttons are associated with. Specifically, change either the button color or the text color on the button.

Does anyone know if this is possible and would be able to help on how to accomplish this?

Thanks
MK
 
You will have to do it with VB code. So go to your command button and display properties, select the event tab and then a suitable event, after update or something like that. select the box at the end and build code.
The private sub part will already be created so enter something like the example between the Private and end subs.

Change the Text1 and command 29 for your control references.

Code:
Private Sub Text1_AfterUpdate()
 
Command29.Enabled = True
Command29.FontBold = True
 
End Sub
 
pl456 had the right general idea, but you have to check to see whether the textbox has data in it or not; AfterUpdate will also fire if data is deleted from the textbox.

Code:
Private Sub YourTextBox_AfterUpdate()
  If Not IsNull(Me.YourTextBox) then
   YourCommandButton.ForeColor = vbRed
  Else
    YourCommandButton.ForeColor = vbBlack
  End If
End Sub

This way, if data was entered into YourTextBox, the text for YourCommandButton would be changed to Red, but if a mistake was made, and the data in YourTextBox was deleted, the text for YourCommandButton would revert back to Black.
 
Thanks Guys...I think I have it working now.
 

Users who are viewing this thread

Back
Top Bottom