Results 1 to 5 of 5
  1. #1
    Ashe is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Location
    Blacksburg VA
    Posts
    65

    Enable controls when form loads in If statement

    Hello
    I have a form that brings up a selected record chosen by the user (from a separate filter form).

    Some controls are enabled/disabled based on other control values. The dependent controls are disabled by default and I am using an if statement to re-enable them. When the form loads a record, I would like it to read the control values and enable some controls based on what is currently in the record. I must be missing a step, because the my If statement is not enabling any of these controls.

    This is just an example for one control box that I've been testing:


    Private Sub Form_Load()
    Me!cboProject.SetFocus

    If Me!lstRegulation = "Yes" Then
    cboRegulation.Enabled = True
    End If

    End Sub
    When the value in lstRegulation is Yes, cboRegulation remains disabled.
    I tried using Me!lstRegulation.value= "Yes", but to no avail.

    Any idea what I'm missing?
    Thank you!

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    From your naming of the control, it looks like "Me!lstRegulation" is a list box. What is the value of the list box when the form loads? Try this:


    Code:
    Private Sub Form_Load()
    Me!cboProject.SetFocus
    
    msgbox Me!lstRegulation  ' <<--
    
    If Me!lstRegulation = "Yes" Then
    cboRegulation.Enabled = True
    End If
    
    End Sub
    Is the bound column of the list box a text field? And there are entries with the word "YES"?

  3. #3
    Ashe is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Location
    Blacksburg VA
    Posts
    65
    Yes- lstRegulation is a bound list box. The value is the list box will either be "Yes" or "No." In instances where lstRegulation=Yes, the combo box cboRegulation should be enabled.

    Using your suggested code, the box is now enabled when lstRegulation=Yes, which is great! Except, I have the message box popping up with "Yes" as the message. Is there a way I can suppress that?

    Thanks for your help!

  4. #4
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Comment out or remove the line

    Code:
    msgbox Me!lstRegulation  ' <<--

  5. #5
    Ashe is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Location
    Blacksburg VA
    Posts
    65
    When this line is removed, cboRegulation is not changed to enabled.

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

Similar Threads

  1. Table loads too slowly
    By pcbrush in forum Access
    Replies: 8
    Last Post: 11-24-2010, 06:35 PM
  2. Enable button in the master form when clicking in the detail
    By DistillingAccess in forum Programming
    Replies: 8
    Last Post: 08-03-2010, 10:54 AM
  3. form controls & recordset
    By slow&steady in forum Forms
    Replies: 2
    Last Post: 06-25-2010, 02:49 PM
  4. list box not updating until form loads
    By cowboy in forum Forms
    Replies: 3
    Last Post: 03-12-2010, 12:02 PM
  5. Accessing form controls
    By dante in forum Forms
    Replies: 15
    Last Post: 07-28-2009, 08:26 AM

Tags for this Thread

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