Disable Button If

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to Disbable a Button if there is any information in any of a
number of different fields?
 
Try something like

Me.ButtonName.Enabled = (IsNull(Me.FieldName1) And IsNull(Me.FieldName2))

If any of the fields, field1 or field2, wont be empty the button will be
disabled, else if both empty it will be enabled.

Run this code on the after update event of the text boxes
 
yes,

you can use the form current event to test values:

'~~~~~~~~~~~
Private Sub Form_Current()
dim mBoo as boolean
mBoo = true
if me.controlname = somevalue then mBoo = false
if me.fieldname = somevalue then mBoo = false
if someOthercondition then mBoo = false
'etc
me.CommandButton_controlname.enabled = mBoo
End Sub
'~~~~~~~~~~~

you can use the AfterUpdate event of particular control to switch the
enabled status during form entry

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
That worked, but once if I select another store the button stays disabled
even if that store has no data in these fields. Is there a way to tell it to
disable only if that particular store had data in it?

I have all of our stores on one table and it where you select the store
number and fills in the store data on the form. The date and hours worked
data is manually entered. There are 12 fields for each Cycle(Month) that has
the date and hours worked. Most stores will only have 3 or 4 visits per year
so I have a Save button set up when the first entry is made on a store to
append to a table. If they need to add another visit to this store, I have a
seperate button to edit the existing store that has already be saved in the
table from the first entry. I want to disable that original Save button if
there is already data in one of these fields so it doesn't get saved twice in
the table. I am just learning coding so any help that isn't too complicated
is apprectiated.
 
If you change the data in text boxes using code or by changing the
record, the AfterUpdate event will not be run

also put the code on the form Current event so it runs when records change

if you use code to change values, add this to your code as well

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 

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

Back
Top