Results 1 to 6 of 6
  1. #1
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317

    Dependent option group problem

    Hi Folks

    This is probably a really simply one, but I'm trying to create an option group (Frame 181) and a text box (Text190) that are disabled unless an option is selected in an earlier option group (Frame 166). I thought this would work:
    Private Sub Frame166_AfterUpdate()
    If IsNull(Frame166) Then Frame181.Enabled = False
    If Not IsNull(Frame166) Then Frame181.Enabled = True


    If IsNull(Frame166) Then Text190.Enabled = False
    If Not IsNull(Frame166) Then Text190.Enabled = True
    End Sub
    And it does work up to a point. However, when an option is selected in Frame166 in one record, it enables Frame181 and Text190 in all other records as well. How do I get Frame166 to interract with Frame181 and Text190 in the current record only? Or am I going about this in completely the wrong way?

    Remster

  2. #2
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    Add code in the OnCurrent event of the Form to see if the option is selected in Frame166. If so, enable the other objects. If not, disable them.

  3. #3
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    Hello again. So much for my prediction that I wouldn't be back until next week!

    I've tried just taking the middle four rows from the above code and sticking them in the On Current event, but I take it you mean something a bit more complex than that (because it doesn't work). Can you give me any pointers?

    By the way, the idea is that Frame181 is enabled if (and only if) any selection is made in Frame166.

  4. #4
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    I did it this way:
    Code:
    Private Sub Form_Current()
        Me.Frame181.Enabled = Not IsNull(Me.Frame166.Value)
        Me.Text190.Enabled = Not IsNull(Me.Frame166.Value)
    End Sub
    I would use the same code in the OnClick event for Frame166

    See the sample if you want to try it out:

  5. #5
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    Yep, that works. As a matter of fact, I also want to highlight Frame13 and Text2 in yellow if they themselves are blank. I don't know how to handle doubling up on equals signs in VBA (any ideas?) so I resorted to conditional statements for that:
    If IsNull(Me.Frame13.Value) Then Me.Frame13.BackColor = vbYellow
    If IsNull(Me.txtText2.Value) Then Me.txtText2.BackColor = vbYellow
    If Not IsNull(Me.Frame13.Value) Then Me.Frame13.BackColor = vbWhite
    If Not IsNull(Me.txtText2.Value) Then Me.txtText2.BackColor = vbWhite
    This seems to work, though I think I'll keep it simple and use conditional formatting for the text box. As a matter of interest, why are the OnClick events necessary?

  6. #6
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    Quote Originally Posted by Remster View Post
    As a matter of interest, why are the OnClick events necessary?
    The reason you want to use it in the OnClick event is to get it to update immediately. Otherwise, it would only enable when you move away from the record and come back to it.

    Your other code should be fine for it as long as you include it in the same places.

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

Similar Threads

  1. Option Group - Borders are gone
    By cevatyildiz in forum Forms
    Replies: 0
    Last Post: 04-30-2010, 06:08 AM
  2. option group radio buttons
    By ManC in forum Forms
    Replies: 9
    Last Post: 03-08-2010, 03:46 AM
  3. Option Group
    By huskies in forum Forms
    Replies: 9
    Last Post: 12-02-2009, 12:06 PM
  4. option group in form
    By mawa4492 in forum Forms
    Replies: 1
    Last Post: 08-05-2009, 02:49 PM
  5. Option Group broken out
    By dcecil in forum Reports
    Replies: 3
    Last Post: 04-21-2009, 10:30 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