Results 1 to 3 of 3
  1. #1
    Reaper is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2011
    Posts
    57

    Command button dis-enabling

    I have a form that is basically a menu of items.



    I want to disable some of the buttons based on selections made in a "setup" form. I have the following code in the setup form that has a list of check boxes. When a check box is clicked it runs this code and toggles the "enable" property of the button.

    Works great until the user closes the original form and reopens it. Then it reopens with the original enabled settings. It seems that the control property embedded in the control at design time is overriding the code to change it when the form reopens.

    Any suggestions?


    Private Sub Auditenable_Click()

    On Error GoTo Err_AuditEnable_Click

    If Auditenable = False Then
    Forms!scale_ticket_switchboard.Controls!Audit.Enab led = False
    Else:
    Forms!scale_ticket_switchboard.Controls!Audit.Enab led = True
    End If

    Exit_AuditEnable_Click:
    Exit Sub

    Err_AuditEnable_Click:
    MsgBox Err.Description
    Resume Exit_AuditEnable_Click

    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You'd want the same code in the current event of the form. Or a function called from both places.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Toyman is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    233
    Quote Originally Posted by Reaper View Post
    I have a form that is basically a menu of items.

    I want to disable some of the buttons based on selections made in a "setup" form. I have the following code in the setup form that has a list of check boxes. When a check box is clicked it runs this code and toggles the "enable" property of the button.

    Works great until the user closes the original form and reopens it. Then it reopens with the original enabled settings. It seems that the control property embedded in the control at design time is overriding the code to change it when the form reopens.

    Any suggestions?

    Private Sub Auditenable_Click()

    On Error GoTo Err_AuditEnable_Click

    If Auditenable = False Then
    Forms!scale_ticket_switchboard.Controls!Audit.Enab led = False
    Else:
    Forms!scale_ticket_switchboard.Controls!Audit.Enab led = True
    End If

    Exit_AuditEnable_Click:
    Exit Sub

    Err_AuditEnable_Click:
    MsgBox Err.Description
    Resume Exit_AuditEnable_Click

    End Sub
    When you say the user closes the form and re-opens, do you mean that the user actually exits the db or just closes the form with the db still open. If the db closes, there is nothing you can do. The form will always open to the saved design setting. However, if the db don't close and the user simply closes the form and reopen, then you can assigned the true/false value of "Auditenable" to a public veriable during the closing of the form. You can then set the value from the public veriable to "Auditenable" during the on-load event of the form and then run the Auditenable_Click

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

Similar Threads

  1. Replies: 1
    Last Post: 11-21-2011, 07:58 AM
  2. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  3. Command Button
    By nashr1928 in forum Forms
    Replies: 2
    Last Post: 07-05-2010, 08:02 PM
  4. Command Button
    By nashr1928 in forum Forms
    Replies: 1
    Last Post: 07-05-2010, 07:05 PM
  5. Command Button Help!
    By arthura in forum Programming
    Replies: 3
    Last Post: 06-30-2009, 12:55 PM

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