If a checkbox is checked in another form

George_E

Registered User.
Local time
Today, 13:26
Joined
Sep 28, 2009
Messages
32
Hey guys

I have a few subreports in one report. I want the condition where if a checkbox is checked in another form to determine if the subreport is going to be visible or not in the main report. Below is a snippet of the code I am using but it doesnt seem to be working.

Code:
Private Sub Report_Open(Cancel As Integer)
If ([Forms]![frmCars1]![Check29] = "True") Then
Visibility = True
Else
Visibility = False
End Sub
Going into a little more detail. Cars1 is the form where the checkbox is.
I have placed this code in the "On open" properties of the subreport.

The reason I am doing this is because I have about 3 reports and whilst each report is independant in its own right, sometimes I may need these reports to merge into one.

Hope you guys can solve where I am going wrong.

George
 
Hey guys

After reviewing my snippet in the post above, it couldnt be further from the truth.
Below is a more refined snippet:
Code:
If ([Forms]![frmCars1]![ChckAss] = "True") Then
rptIssSummary.Visible = True
End If

FrmsCars1 is my form, ChckAss is the checkbox in that form and rptIssSummary is the report which I want to appear when the checkbox is ticked.

Once again this is in the open report property of rptIssSummary

I know I am going wrong somewhere but I cant figure where exactly

Unless

Code:
rptIssSummary.Visible = True

Is where I am going wrong

:confused:

George
 
it should be:
If (Forms![frmCars1].[ChckAss] = "True") Then

you can also put a message box to know what you get
messagebox Forms![frmCars1].[ChckAss]
 
Thankyou smig, I will try that and let you know

Thanks again
 
Your code should actually be:

Code:
Private Sub Report_Open(Cancel As Integer)
    If ([Forms]![frmCars1]![Check29] = True) Then
        Visible = True
    Else
        Visible = False
    End If
End Sub

Since check29 is a boolean field it's value is not "True", it's either 0 or -1, so you can use different way's to check it.

Code:
If ([Forms]![frmCars1]![Check29] = -1) Then...

Code:
If ([Forms]![frmCars1]![Check29] <> 0) Then

The quotes around "True" means to check for the word True, which isen't there and you will never execute the true-statement.

JR:)
 
Hey guys, Jr you are right!

Below is a snippet of the code:

Code:
Private Sub Report_Open(Cancel As Integer)
    If ([Forms]![Cars1]![ChckAss] = True) Then
        Visible = True
    Else
        Visible = False
    End If
End Sub

I was also majorly going wrong with the fact that the form was called Cars1 instead of frmCars1. :o

Couldnt have got there without the snippet of code you posted though.

Thanks again guys, I know I will have a good sleep tonight :)

George
 
sorry, puting the True in quates was a mistake.
-1 = true
0 = false

but I also suggest to use a message box for checking what you get ;)
 

Users who are viewing this thread

Back
Top Bottom