Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2012
    Posts
    2

    Question Unanswered: Use option box to determine whether text box is/isnt visible

    Hi,

    I am creating a form for data to be entered into the Invoice. The end-user will determine whether the customer is a member / just a paying customer by clicking the option box, once the customer option is clicked the membership text box should be invisible vice versa.

    This is what I have so far but it isn't working. I am a new at code's / building

    Private Sub option4customer_click()
    If Me.option4customer.Value = -1 Then
    Me.Customer_ID_Label.Visible = True
    Me.CustomeriD.Visible = True
    Me.Membership_ID_Label.Visible = False
    Me.Membershipid.Visible = False
    Else
    Me.Customer_ID_Label.Visible = False
    Me.CustomeriD.Visible = False
    End If
    Me.Refresh
    End Sub

    Private Sub option4member_Click()
    If option4member.Value = -1 Then
    Me.Membership_ID_Label.Visible = True
    Me.Membershipid.Visible = True
    Me.Customer_ID_Label.Visible = False
    Me.CustomeriD.Visible = False
    Else
    Me.Membership_ID_Label.Visible = False
    Me.Membershipid.Visible = False
    End If


    It will be better if it could be locked rather than invisible. Please help, thank you.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    1. Both option buttons must be placed into an option group control.
    2. You never use the values nor the events of the option buttons directly, you use the option group instead.
    3. Option group - Name: Frame_MemberCustomer
    4. Option button - Name: Option_Member, Option value: 1
    5. Option button - Name: Option_Customer, Option value: 2
    6. In the form module:
    Code:
    Private Sub Frame_MemberCustomer_AfterUpdate()
    
    
        Select Case Me.Frame_MemberCustomer
            Case 1
                Me.CustomeriD.Visible = False
                Me.Membershipid.Visible = True
            Case 2
                Me.CustomeriD.Visible = True
                Me.Membershipid.Visible = False
        End Select
        
    End Sub
    If you prefer to enable/disable the controls instead of making them visible/invisible, use:
    Code:
    Private Sub Frame_MemberCustomer_AfterUpdate()
    
        Select Case Me.Frame_MemberCustomer
            Case 1
                Me.CustomeriD.Enabled = False
                Me.Membershipid.Enabled = True
            Case 2
                Me.CustomeriD.Enabled = True
                Me.Membershipid.Enabled = False
        End Select
        
    End Sub
    Have a nice day!

  3. #3
    Join Date
    Mar 2012
    Posts
    2

    'File not found'

    When going into form view a pop-up is displayed saying 'File not found' and directs me back to the codes.

    I named the group what you did and I also named the option boxes what you did.

    What did I do wrong?

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    I don't see how that code can raise a 'File not found' error. What happens when you try to compile the project?
    Have a nice day!

  5. #5
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    I don't understand why you need an option box. I would make a checkbox (True/False) and default to one of them. For example, you would default the checkbox to No/False. You would also default membershipid to False/No, and CustomerID to True/Yes. You would prompt, for example, "Is this entity a Member?" If the checkbox is clicked, you can then reverse the display of the ID fields.

    An alternative to this is to ask the question before opening the form so the form opens with the necessary fields already displaying correctly.

    Sam

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
  •