Need syntax help

  • Thread starter Albert D. Kallal
  • 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?
 
D

Dirk Goldgar

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 & "'"
 
B

Bob Dzimbowski

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
 
B

Bob Dzimbowski

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

Top