Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2007

Tip: Looking for answers? Try searching our database.

Disable Button If

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Supe - 15 Mar 2007 17:42 GMT
Is there a way to Disbable a Button if there is any information in any of a
number of different fields?
Ofer Cohen - 15 Mar 2007 18:43 GMT
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

Signature

Good Luck
BS"D

> Is there a way to Disbable a Button if there is any information in any of a
> number of different fields?
Supe - 15 Mar 2007 19:55 GMT
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.    

> Try something like
>
[quoted text clipped - 8 lines]
> > Is there a way to Disbable a Button if there is any information in any of a
> > number of different fields?
strive4peace - 16 Mar 2007 15:08 GMT
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
  *

> 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
[quoted text clipped - 24 lines]
>>> Is there a way to Disbable a Button if there is any information in any of a
>>> number of different fields?
strive4peace - 15 Mar 2007 18:47 GMT
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
  *

> Is there a way to Disbable a Button if there is any information in any of a
> number of different fields?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.