Need syntax help

  • Thread starter Thread starter Albert D. Kallal
  • Start date Start date
A

Albert D. Kallal

Text values need to be surround in quotes. You can use single quotes.
Case 2
stDocName = "rptGeneral"
stLinkCriteria = "sRecLotNo = '" & Me.txtLotNo & "'"

End Select

DoCmd.OpenReport stDocName, acPreview, "qrygeneral", stLinkCriteria

Also, are you sure you need "qrygeneral" as a filter name?
 
Bob Dzimbowski said:
For the following code I got case 1 to work but case 2 doesn't work.
The only difference I can tell is that sRecLotNo is text while
sRecWorkOrd is numeric. I have tried all sorts of combinations to try
and get case 2 to work to no avail.

Any help appreciated.

Bob

Select Case Forms![frmReports].[rptNum]
Case 1
stDocName = "rptGeneral"
stLinkCriteria = "sRecWorkOrd = " & Me.txtOrderNo

Case 2
stDocName = "rptGeneral"
stLinkCriteria = "sRecLotNo = " & Me.txtLotNo

End Select

DoCmd.OpenReport stDocName, acPreview, "qrygeneral",
stLinkCriteria

Since sRecLotNo is text, the value you pass to it must be enclosed in
single or double quotes. If txtLotNo won't ever contain a single-quote
character ('), that may be the simplest one to use. Try this:

stLinkCriteria = "sRecLotNo = '" & Me.txtLotNo & "'"
 
For the following code I got case 1 to work but case 2 doesn't work. The
only difference I can tell is that sRecLotNo is text while sRecWorkOrd is
numeric. I have tried all sorts of combinations to try and get case 2 to
work to no avail.

Any help appreciated.

Bob

Select Case Forms![frmReports].[rptNum]
Case 1
stDocName = "rptGeneral"
stLinkCriteria = "sRecWorkOrd = " & Me.txtOrderNo

Case 2
stDocName = "rptGeneral"
stLinkCriteria = "sRecLotNo = " & Me.txtLotNo

End Select

DoCmd.OpenReport stDocName, acPreview, "qrygeneral", stLinkCriteria
 
Wow, thanks. Of all the combinations I tried, I didn't even come close to
that. It worked like a charm.

BDz.
 

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

Similar Threads

Print Report using current data on Form 2
stLinkCriteria syntax help 2
Print One Record From Form 2
Type Mismatch 3
MsgBox results 11
reference to opened form 2
Syntax Error (Missing Operator) 3
DoCmd.SendObject 2

Back
Top