Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Toggle Text Box (Access 2000)

    I'm looking for sample code to toggle the visibility of a text box on a report. The setting is derived from the value of another textbox.

    Thanks

  2. #2
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toggle Text Box (Access 2000)

    Thanks for the quick response

    How do the code a report. Currently I've got the following in the control source of a textbox : =IIf([SumofM1].[Value]=0,"M1"). How do I change this value in VBA. Example
    Quess:

    Load Report
    Set Values of certain Text Boxes
    Display Report

    Thanks

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Toggle Text Box (Access 2000)

    I don't understand how this relates to the original question. Do you want to change the visibility of a text box, or change the value of a text box, or what?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Toggle Text Box (Access 2000)

    Sorry, I didn't read the question carefully enough - I missed that it is about a report

    The code to toggle visibility is simple, but when and how do you want to invoke it? After the user has changed the text in the other text box? If so, use the After Update event:

    Private Sub TextBox2_AfterUpdate()
    If TextBox2 = ... Then ' your condition here
    TextBox1.Visible = True
    Else
    TextBox1.Visible = False
    End If
    End Sub

  5. #5
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toggle Text Box (Access 2000)

    Sorry that I'm confusing you.

    Let my try again.

    I'm running a report. Certain Textboxes (Example Textbox1 and Textbox2) on the report header should be visible on the report if the value of Textbox3 in the same header ends with a A. If it does not end on an A then both Textboxes should be not visible.

    I hope I'm more clear now

    Thanks

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Toggle Text Box (Access 2000)

    Thanks for the explanation, and please accept my apologies for not reading your original question carefully.

    You can use the On Format event of the report header to set the visibility of controls in that header.

    Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
    If Right([TextBox3], 1) = "A" Then
    TextBox1.Visible = True
    TextBox2.Visible = True
    Else
    TextBox1.Visible = False
    TextBox2.Visible = False
    End If
    End Sub

  7. #7
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toggle Text Box (Access 2000)

    Thanks Hans <img src=/S/bow.gif border=0 alt=bow width=15 height=15>

    I knew if only I can get the problem across you or any of the others would have an answer in a flash

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •