Results 1 to 5 of 5
  1. #1
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398

    Enabling controls on a form

    On a form used for editing records, after retrieving a record, some of the fields are set to enabled = false. After saving the record, I need to make sure all the fields on the form are set to enabled = true. I've written this code.

    For Each ctl In Me.Controls
    Debug.Print strGroup
    If ctl.Tag = strGroup Then


    Debug.Print ctl
    ctl.Enabled = "True"

    End If
    Next ctl

    When testing, it goes through the first control without any problem, when it reaches the second contol, after pressing F8 on the statement debug.print ctl, it immediately ends the function, and returns me to where the function call statement was made.

    If the debug statement is not within the code, after pressing F8 on the statement ctl.Enabled = "True", it ends the function like above.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    What is strGroup?

    As you step through the loop you will need to test what kind of control it is. Some controls do not have an Enabled property.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Within each control on this form, I've put in a tag. Currently my tags are Group1, Group2, Group3. Before I run this loop, I assign the correct group to strGroup.

    How do I determine the type of control?

    Which controls do not have an enabled property?

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,543
    Quote Originally Posted by crowegreg View Post
    How do I determine the type of control?

    Which controls do not have an enabled property?
    Take a look at "ControlType Property" in the VBA Help file.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Thanks, I'll read about controls.

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

Similar Threads

  1. Replies: 5
    Last Post: 11-13-2012, 04:45 PM
  2. Enabling commands for different users
    By glen in forum Forms
    Replies: 28
    Last Post: 10-11-2012, 03:36 PM
  3. Enabling fields in form
    By Kivan in forum Programming
    Replies: 8
    Last Post: 08-22-2012, 03:44 AM
  4. Replies: 1
    Last Post: 11-21-2011, 07:58 AM
  5. Replies: 2
    Last Post: 01-15-2011, 10:56 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