Form to report by CMD BTN

K

KAnoe

I have a form that I would like to use to open a report in the preview mode.
I think that I'm close but I keep getting an error msg On the
DoCmd.OpenReport Line. Here is the code that I'm using.

Private Sub cmd_btn_Print_Record_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Client_Rpt"

stLinkCriteria = "[PL-Key_ID]=" & " Me![PL-Key_ID] & "
DoCmd.OpenReport stDocName, , , stLinkCriteria

Exit_cmd_btn_Print_Record_Click:
Exit Sub
End Sub
 
D

Douglas J. Steele

That should be

stLinkCriteria = "[PL-Key_ID]=" & Me![PL-Key_ID]

if PL-Key_ID is numeric, or one of the following:

stLinkCriteria = "[PL-Key_ID]=" & Chr$(34) & Me![PL-Key_ID] & Chr$(34)
stLinkCriteria = "[PL-Key_ID]=""" & Me![PL-Key_ID] & """"
stLinkCriteria = "[PL-Key_ID]='" & Me![PL-Key_ID] & "'"

if it's text.
 
K

KAnoe

Thanks!!!

Works Great!!!!

Douglas J. Steele said:
That should be

stLinkCriteria = "[PL-Key_ID]=" & Me![PL-Key_ID]

if PL-Key_ID is numeric, or one of the following:

stLinkCriteria = "[PL-Key_ID]=" & Chr$(34) & Me![PL-Key_ID] & Chr$(34)
stLinkCriteria = "[PL-Key_ID]=""" & Me![PL-Key_ID] & """"
stLinkCriteria = "[PL-Key_ID]='" & Me![PL-Key_ID] & "'"

if it's text.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



KAnoe said:
I have a form that I would like to use to open a report in the preview
mode.
I think that I'm close but I keep getting an error msg On the
DoCmd.OpenReport Line. Here is the code that I'm using.

Private Sub cmd_btn_Print_Record_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Client_Rpt"

stLinkCriteria = "[PL-Key_ID]=" & " Me![PL-Key_ID] & "
DoCmd.OpenReport stDocName, , , stLinkCriteria

Exit_cmd_btn_Print_Record_Click:
Exit Sub
End Sub
 

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