Open report with multiple criteria

CEH

Curtis
Local time
Today, 07:29
Joined
Oct 22, 2004
Messages
1,187
OK... I've been searching the forum for over an hour... this one seems simple, but can't find an answer. I think I am having a syntax problem.... but.... What I am trying to do is open a report to show only certain records... sounds simple enough.... BUT.......... Can't get it to ork when using 2 criteria.
The first....

Dim stDocName As String
Dim strWhere As String

strWhere = "[ProjectID]=" & Me![ProjectID]
stDocName = "rptClientBill"

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport stDocName, acPreview, , strWhere

This works fine. But when I try to add a second criteria to it... I get different errors...
I want to add basically this..
([frmBillSubform].Form![HoursBilled]) = True
This pulls from a subform only the records after a checkbox is checked. (HoursBilled)

I have tried ..........
strWhere = "[ProjectID]=" & Me![ProjectID] & ([frmBillSubform].Form![HoursBilled]) = True

And..............
strWhere = "[ProjectID]=" & Me![ProjectID]
strWhere = strWhere & ([frmBillSubform].Form![HoursBilled]) = True

Still nothing works.... is this a syntax error??
 
this bit of the expression is the problem

the second bit of the where clause

[frmBillSubform].Form![HoursBilled] = True can't define the query as it stands - you need a way of getting this test into your source query
 
I think it might work if you use the following, where I have simply replaced the TRUE vb Keyword with the integer value for true which I think is -1

I.e.

strWhere = "[ProjectID]=" & Me![ProjectID] & " AND ([frmBillSubform].Form![HoursBilled]) = -1"

W1dge
 

Users who are viewing this thread

Back
Top Bottom