Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2009
    Posts
    16

    Unanswered: unknown VBA error

    I have a report that has a yes and a no field which both are hidden.
    In one of my forms I have a ckeck box if that checkbox is true then show yes (label56) if it is false then show no (label57) the problem is if I dont check it I get an error on Me.Label56.Visible = (Me.label66 = True)

    Code

    Private Sub Report_Activate()

    Me.Label56.Visible = (Me.label66 = True)
    Me.Label57.Visible = (Me.label66 = False)

    End Sub


    Thanks
    Last edited by ratte; 01-21-10 at 22:06.

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    If label66 is indeed a label (not a text box), then you can't test for a true or false value (you should make it a text box or use the .caption to see what the value is of the label).

    ex:
    If me!MyTextBox = True then me.Label56.visible = true else me.Label56.visible = false

    or possibly...

    if me.Label66.caption = "sometext" then me.Label56.visible = true else me.Label56.visible = false
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    But also note that if you're opening a 'report', you may have to reference the report or form directly.

    ex:
    If Forms!MyFormName!MyTextBox = True then Reports!MyReportName.MyLabelField.visible = true.....

    it depends on how you're opening the report, if you have the form open, and when you want to make the field on the report visible/false (which you might want to put in an OnFormat event of the report's detail (or header or footer) section. Again, depends on how you're opening the report and how you're doing this. I'm not sure the Report_Active event of the report is the best place to put your code.
    Last edited by pkstormy; 01-21-10 at 22:41.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Sep 2009
    Posts
    16
    Thanks Mate

  5. #5
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Your welcome.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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