Results 1 to 10 of 10
  1. #1
    George_E is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    4

    Simple question about checkboxes

    Hey guys, I am new to this forum, and also quite a newbie with Access.

    I have a problem in my code and I hope you guys could find it.

    I have a checkbox in one form and what I wish for is if the checkbox is ticked, the sub report is made visible. Thats all I want to do but yet I still cannot get my head around it.

    Below is the snippet of code I am using, I dont know if you guys can tell by looking at it where abouts I am going wrong:

    Code:
    If ([Forms]![frmCars1]![ChckAss] = "True") Then
    rptIssSummary.Visible = True
    End If
    frmCars1 is the form the checkbox is located in. ChckAss is the checkbox in the form and rptIssSummary is the report I want to become visible if the checkbox was ticked.
    May I add this snippet of code is based in "On open" properties of the report.

    I would be gratefull if you guys could help me, I feel as though Ive made a silly mistake somewhere

    George



    Btw, if this is posted in the wrong section of the forum, I do apologise to all the mods

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    A CheckBox is equal to:
    True or False
    0 or 1
    ...but not "True"
    It is a numerical value nor a string.

  3. #3
    George_E is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    4
    Thats a point, thankyou for your response ruralguy.

    I am still having problems making the report visible though

    George

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I have not used SubReportControls before. Do thay have a .Visible property? Not the SubReport but the SubReportControl.

  5. #5
    George_E is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    4
    Yes they do, in the properties section you can set whether you wish for it to be visible or not.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Is the frmCars1 still open? Can you get that code to do anything else so you can make sure it is running?

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Be careful of the advice you are getting on AWF from smig. I know their heart is in the right place. I would think the following syntax would be enough:
    rptIssSummary.Visible = Forms!frmCars1!ChckAss

  8. #8
    George_E is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    4
    Hello, the problem is solved!

    For future reference and for any others that may stumble along the same problem, below is a snippet of the correct code:
    Private Sub Report_Open(Cancel As Integer)
    If ([Forms]![Cars1]![ChckAss] = True) Then
    Visible = True
    Else
    Visible = False
    End If
    End Sub
    Thanks again Rural guy.

    George

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're welcome. So this is in the Open event of the SubReport? You left that little detail out. Shorter code with no If's:
    Code:
    Private Sub Report_Open(Cancel As Integer)
       Me.Visible = [Forms]![Cars1]![ChckAss]
    End Sub

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I would give yourself a pat on the back and then follow the link in my sig and mark this thread as Solved.

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

Similar Threads

  1. Simple question
    By KenM in forum Queries
    Replies: 1
    Last Post: 11-10-2009, 03:32 PM
  2. Simple question?
    By roads.zx in forum Access
    Replies: 0
    Last Post: 10-15-2009, 04:56 PM
  3. Very simple question!
    By fiddley in forum Programming
    Replies: 2
    Last Post: 04-28-2009, 02:16 AM
  4. Simple but hard question
    By andymok in forum Reports
    Replies: 1
    Last Post: 09-20-2007, 09:19 AM
  5. Probably a simple report question
    By gmurrie in forum Reports
    Replies: 1
    Last Post: 12-28-2005, 09:19 PM

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