![]() |
Excel and Office
RAQ Making an Access form field enabled or disabled (or visible or invisible) based on the value of another control |
|
Q: I am making a Access database of recipes I would like to try. If I tried it I want to say what kind of rating and any amendments. So far, I was doing good till on the recipe form (FrmRecipes) there is a tried check box and a tried (cmdTried) button that opens frmTried. I want that the tried button not be visible or disabled till tried check box is checked. I wrote the following in VBA but how do I tell it that when it goes to a new record to disenable it? Private Sub Tried_Click() If Tried = -1 Then CmdTried.Enabled =True End If End Sub A: Your issue here is which EVENT you place your code in. If you look up 'form object' in Access VBA help, you can find a full list of the events available. You've probably found that putting your code in a form event allows it to run at the right time. To reset your field when the record changes, you need some code in the 'Current' event of the form, which runs whenever the user moves to another record in the form. Your code can be simplified, by the way, to a single line which will work in any event: CmdTried.Enabled=Tried Replace the enabled with Visible if you want the control to disappear and reappear.
|
|