Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2022
    Posts
    17

    How to disable command buttons until conditions are met!

    Hi, What I am attempting to do is have the buttons (Auto) (Home) disabled until the Cust ID is entered. (screen shots attached in attempt to make my words clearer!)
    Even though the Cust ID is a required field I don’t get the error message until after the Auto button is clicked and it takes the user to the Auto Policies Page (see attached). Unfortunately, I am already using an autonumber field.
    I have a Client form (see attached) with only client and family info. The Enter Auto and Enter Home buttons were created using macro Wizards. Each button goes to another form and sets different fields (see attached)
    When the Enter Auto or Enter Home buttons are clicked, we are taken to the respective pages and importing the insured name (by Concatenation) and below that the Cust ID. If the Cust ID isn’t entered on the Clients page it doesn’t appear on any other pages and cannot be saved.


    So, in a nutshell, I don’t want to leave the Client page until the all the required information is inputted, and maybe have my own Error Message. This database has evolved over the last 15 years. Had I known better everything would have been done with VBA.
    Any suggestions would be greatly appreciated!
    Frank
    Attached Files Attached Files

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,702
    Those are pdf downloads - not going to do that but maybe that's just me. If you have code you want to show, post it within code tags (use # button on posting toolbar).
    If you want to show forms in any view, post a pic (not the easiest thing to do here, but there is guidance at the top of the forum page - How to attach files)
    Had I known better everything would have been done with VBA.
    If that means you're using macros, help for that might be a bit limited.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,100
    In the Current event of the Client form disable the two buttons if the Cust_ID is Null:
    Code:
    If IsNull(Me.Cust_ID) Then
        Me.cmdAuto.Enabled=False
        Me.cmdHome.Enabled=False
    End If
    And in the AfterUpdate event of the Cust_ID textbox enable them if something was entered:
    Code:
    If Not IsNull(Me.CUst_ID) Then
        Me.cmdAuto.Enabled=True
        Me.cmdHome.Enabled=True
    End If
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    Join Date
    Sep 2022
    Posts
    17
    Thank you, Vlad
    Works like a charm.
    Frank

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,100
    Happy to help Frank!
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 01-20-2017, 08:16 AM
  2. Replies: 2
    Last Post: 01-19-2017, 02:04 PM
  3. VBA disable Next and Last Buttons
    By Perceptus in forum Programming
    Replies: 5
    Last Post: 09-18-2016, 12:09 PM
  4. Replies: 5
    Last Post: 03-13-2012, 12:28 PM
  5. Disable command button
    By rajulasb in forum Access
    Replies: 2
    Last Post: 08-04-2011, 05:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums