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.
 
Back
Top