OBJECTIVE: Print PDF to file, each record should be a file name =PID (field) - have code issue belo

S

S Himmelrich

I've reviewed google groups for solution, most of the post are
directing to broken links.....here is my attempt at the code, which is
erroring out with 'can't find field "|" referred to in your
expression'.

HERE IS THE CODE (which I found online):

Private Sub Command463_Click()
On Error GoTo Err_Command463_Click

Dim PIDNumber As String
Dim Sql As String
Dim rs As Recordset

Sql = "SELECT * FROM " & [One Pager Status Reports] & " ORDER BY PID"

Set rs = CurrentDb.OpenRecordset(Sql)

With rs

..MoveLast
..MoveFirst

Do Until .EOF = True

PIDNumber = !PID
DoCmd.OutputTo acReport, "Portfolio Project Status Report"

..MoveNext
Loop

End With
rs.Close


'--------Report Open Event (Report1)--------------
Me.caption = PIDNumber

Me.RecordSource = "SELECT * FROM " & [One Pager Status Reports] & "
WHERE PID = '" & PIDNumber & "'"

Exit_Command463_Click:
Exit Sub

Err_Command463_Click:
MsgBox Err.Description
Resume Exit_Command463_Click

End Sub
 
V

Vacuum Sealed

I've reviewed google groups for solution, most of the post are
directing to broken links.....here is my attempt at the code, which is
erroring out with 'can't find field "|" referred to in your
expression'.

HERE IS THE CODE (which I found online):

Private Sub Command463_Click()
On Error GoTo Err_Command463_Click

Dim PIDNumber As String
Dim Sql As String
Dim rs As Recordset

Sql = "SELECT * FROM "& [One Pager Status Reports]& " ORDER BY PID"

Set rs = CurrentDb.OpenRecordset(Sql)

With rs

.MoveLast
.MoveFirst

Do Until .EOF = True

PIDNumber = !PID
DoCmd.OutputTo acReport, "Portfolio Project Status Report"

.MoveNext
Loop

End With
rs.Close


'--------Report Open Event (Report1)--------------
Me.caption = PIDNumber

Me.RecordSource = "SELECT * FROM "& [One Pager Status Reports]& "
WHERE PID = '"& PIDNumber& "'"

Exit_Command463_Click:
Exit Sub

Err_Command463_Click:
MsgBox Err.Description
Resume Exit_Command463_Click

End Sub

I think you need to wrap ["One Pager Status Report"] as it has spaces.

HTH
Mick.
 
S

S Himmelrich

I've reviewed google groups for solution, most of the post are
directing to broken links.....here is my attempt at the code, which is
erroring out with 'can't find field "|" referred to in your
expression'.
HERE IS THE CODE (which I found online):
Private Sub Command463_Click()
On Error GoTo Err_Command463_Click
Dim PIDNumber As String
Dim Sql As String
Dim rs As Recordset
Sql = "SELECT * FROM "&  [One Pager Status Reports]&  " ORDER BY PID"
Set rs = CurrentDb.OpenRecordset(Sql)
With rs

Do Until .EOF = True
PIDNumber = !PID
DoCmd.OutputTo acReport, "Portfolio Project Status Report"

End With
rs.Close
'--------Report Open Event (Report1)--------------
Me.caption = PIDNumber
Me.RecordSource = "SELECT * FROM "&  [One Pager Status Reports]&  "
WHERE PID = '"&  PIDNumber&  "'"
Exit_Command463_Click:
     Exit Sub
Err_Command463_Click:
     MsgBox Err.Description
     Resume Exit_Command463_Click

I think you need to wrap ["One Pager Status Report"] as it has spaces.

HTH
Mick.- Hide quoted text -

- Show quoted text -

Tried that, same error
 

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