CheckBox

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

Hi, I have a report that is run from different queries.
On my Form, I want to put a check box, which by checking
it, it will cause one of the queries of the report to
EXEMPT records that have a certain field...so it won't
show on the report. I was thinking to code for the
cmdRUNREPORT...IF chkBOX=True then <> "Shanghia" and
<> "JAPAN" in that particular query..just dont know how to
code it...or maybe in the query criteria put in somehow
[Forms]![SmallBusiness][chkox]=True, <>Shanghia And <>
Japan....please help out..I think im on the right track
not sure.
 
Alex said:
Hi, I have a report that is run from different queries.
On my Form, I want to put a check box, which by checking
it, it will cause one of the queries of the report to
EXEMPT records that have a certain field...so it won't
show on the report. I was thinking to code for the
cmdRUNREPORT...IF chkBOX=True then <> "Shanghia" and
<> "JAPAN" in that particular query..just dont know how to
code it...or maybe in the query criteria put in somehow
[Forms]![SmallBusiness][chkox]=True, <>Shanghia And <>
Japan....please help out..I think im on the right track
not sure.


In the code that opens the report, use the OpenReport
method's WhereCondition argument to filter the report.

. . .
strWhere = "Not [country] IN('Shanghia','Japan')"
DoCmd.OpenReport strDoc, , ,strWhere
. . .
 
I have a similar situation. I have a per record form
(frmContributionLetter)with a check box (chkActivate). If the
checkbox is checked, a textbox (MidManagerIncentive) is enabled so I
can enter a dollar amount. If it is not checked, it will be disabled.
Then I have a Preview Report cmd button at the bottom to see this
individual records report detail. I have the following code below in
the OnClick procedure:

Private Sub cmdPreview_Click()
Dim stDocName As String
Dim stCompleted As String
Dim stNotCompleted As String
Dim strWhere As String

stDocName = "rptIndividualContribution-Incentive"
stDocReport = "rptIndividualContribution"
strWhere = "[Lastname] =" & Me!LastName

If Me.chkActivate.Value = Yes Then

DoCmd.OpenReport stDocName, acViewPreview, , stCompleted
Else
DoCmd.OpenReport stDocReport, acViewPreview, , stNotCompleted
End If

End Sub

Unfortunately, whether the checkbox is marked or isn't, it brings up
the same report, one with data - the other without. If I remove the
following from the query that the report looks at:
[forms]![frmContributionletter]![LastName] then I see the right
information but for ALL records, not just the one I am updating. Any
help would be greatly appreciated. Thanks!

Marshall Barton said:
Alex said:
Hi, I have a report that is run from different queries.
On my Form, I want to put a check box, which by checking
it, it will cause one of the queries of the report to
EXEMPT records that have a certain field...so it won't
show on the report. I was thinking to code for the
cmdRUNREPORT...IF chkBOX=True then <> "Shanghia" and
<> "JAPAN" in that particular query..just dont know how to
code it...or maybe in the query criteria put in somehow
[Forms]![SmallBusiness][chkox]=True, <>Shanghia And <>
Japan....please help out..I think im on the right track
not sure.


In the code that opens the report, use the OpenReport
method's WhereCondition argument to filter the report.

. . .
strWhere = "Not [country] IN('Shanghia','Japan')"
DoCmd.OpenReport strDoc, , ,strWhere
. . .
 
Work22 said:
I have a similar situation. I have a per record form
(frmContributionLetter)with a check box (chkActivate). If the
checkbox is checked, a textbox (MidManagerIncentive) is enabled so I
can enter a dollar amount. If it is not checked, it will be disabled.
Then I have a Preview Report cmd button at the bottom to see this
individual records report detail. I have the following code below in
the OnClick procedure:

Private Sub cmdPreview_Click()
Dim stDocName As String
Dim stCompleted As String
Dim stNotCompleted As String
Dim strWhere As String

stDocName = "rptIndividualContribution-Incentive"
stDocReport = "rptIndividualContribution"
strWhere = "[Lastname] =" & Me!LastName

If Me.chkActivate.Value = Yes Then

DoCmd.OpenReport stDocName, acViewPreview, , stCompleted
Else
DoCmd.OpenReport stDocReport, acViewPreview, , stNotCompleted
End If

End Sub

Unfortunately, whether the checkbox is marked or isn't, it brings up
the same report, one with data - the other without. If I remove the
following from the query that the report looks at:
[forms]![frmContributionletter]![LastName] then I see the right
information but for ALL records, not just the one I am updating. Any
help would be greatly appreciated. Thanks!


You don't use the strWhere variable anywhere???

A check box does not contain Yes, it is either True or False

Change the query to remove the criteria and try something
more like this:

If Me.chkActivate.Value = True Then
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Else
DoCmd.OpenReport stDocReport, acViewPreview, , strWhere
End If

though I don't know why you need two different reports to do
this??
 
Back
Top