SQL statement

C

Cindy

Can anyone help? I have the following code where I'm
building the strSQL that will act as the report filter.
The problem I have is the date range code.
The reference to the form and fields DSFrom and DSTo are
not evaluated in the strSQL - it holds the forms statement
rather than determining the actual value (i.e. 8/1/03)

'Determine date range
stDate = "WHERE (((PDATracking.DateSubmitted) Between
[Forms]![frmRptSelectbyDist]![DSFrom] And [Forms]!
[frmRptSelectbyDist]![DSTo])"

'Build list of Distributors
For Each varSelected In Me!lstDistributor.ItemsSelected
stDist = stDist + "'" & Me!lstDistributor.ItemData
(varSelected) + "',"
Next varSelected
stDist = "AND (([PDATracking].Distributor) IN (" + Left
(stDist, Len(stDist) - 1) + ")));"

strSQL = "SELECT * FROM [PDATracking] "
strSQL = strSQL + stDate
strSQL = strSQL + stDist

stDocName = "rptPDAbyDist"
DoCmd.OpenReport stDocName, acPreview, strSQL

Thank you

Cindy
 

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