use calendar control to filter report

M

martinmike2

Hello, I am trying to use two calendar controls to provide the
WhereCondition: for a report.

Private Sub cmdOpenRep_Click()
Dim stdocname As String, strPredicate As String
stdocname = "rptMonthHist"
dtStart = Me.Calendar5
dtEnd = Me.ActiveXCtl6
strPredicate = "tblMain.[COMPLETION DATE] > " & dtEnd & " AND < " &
dtStart
DoCmd.OpenReport stdocname, , , WhereCondition:=strPredicate
End Sub


I am getting a 'Missing Syntax' error

any ideas what im doing wrong?
 
R

Rod Plastow

Yes.

You must tediously renominate [COMPLETION DATE] in each and every
comparison; no shortcuts allowed unfortunately.

strPredicate = "tblMain.[COMPLETION DATE] > " & dtEnd & " AND
tblMain.[COMPLETION DATE] < " & dtStart

should get you going.
 
R

Rod Plastow

Just spotted that I think your operators are the wrong way round. Don't you
mean completion date is less than date end and greater than date start?
 
M

martinmike2

Yes.

You must tediously renominate [COMPLETION DATE] in each and every
comparison; no shortcuts allowed unfortunately.

strPredicate = "tblMain.[COMPLETION DATE] > " & dtEnd & " AND
tblMain.[COMPLETION DATE] < " & dtStart

should get you going.



martinmike2 said:
Hello, I am trying to use two calendar controls to provide the
WhereCondition: for a report.
Private Sub cmdOpenRep_Click()
Dim stdocname As String, strPredicate As String
stdocname = "rptMonthHist"
dtStart = Me.Calendar5
dtEnd = Me.ActiveXCtl6
strPredicate = "tblMain.[COMPLETION DATE] > " & dtEnd & " AND < " &
dtStart
DoCmd.OpenReport stdocname, , , WhereCondition:=strPredicate
End Sub
I am getting a 'Missing Syntax' error
any ideas what im doing wrong?- Hide quoted text -

- Show quoted text -

worked like a champ, thnx for kickin my brain back into gear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top