Printing report with single record data from a form

G

Guest

I have a form from wich I want to print the data of a single record on a
report. I have the code for the button to print the report, but it prints all
the records from a table on seperate pages instead of just the single page
with the data I am looking at.

Code is:

Private Sub Print_Requisition_Click()
On Error GoTo Err_Print_Requisition_Click

Me.Dirty = False '

stDocName = "invoices"

DoCmd.OpenReport "invoices", , , "no" & Me.No

Exit_Print_Requisition_Click:
Exit Sub

Err_Print_Requisition_Click:
MsgBox Err.Description
Resume Exit_Print_Requisition_Click

End Sub

Thank you in advance
Ronald
 
G

Guest

I saw what ken snell wrote to another user, and have done the code like that,
but now it prints blank.

code

Private Sub Print_Requisition_Click()
On Error GoTo Err_Print_Requisition_Click

DoCmd.OpenReport "invoices", , , "no=" & Me.No.Value

Exit_Print_Requisition_Click:
Exit Sub

Err_Print_Requisition_Click:
MsgBox Err.Description
Resume Exit_Print_Requisition_Click

No. is my primary key.

Ronald
____________________________________________________________
 
F

fredg

I saw what ken snell wrote to another user, and have done the code like that,
but now it prints blank.

code

Private Sub Print_Requisition_Click()
On Error GoTo Err_Print_Requisition_Click

DoCmd.OpenReport "invoices", , , "no=" & Me.No.Value

Exit_Print_Requisition_Click:
Exit Sub

Err_Print_Requisition_Click:
MsgBox Err.Description
Resume Exit_Print_Requisition_Click

No. is my primary key.

Ronald
____________________________________________________________


Your problem is in the use of the word No as a field name.
Change the field name from No to Num (or any non-reserved word).

No is a reserved Access/VBA/Jet word and should not be used as a
field name.

Also, as written, the where clause is expecting that the datatype of
the No field is a Number, not text. Is that correct?

For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'
 
G

Guest

thanx

fredg said:
Your problem is in the use of the word No as a field name.
Change the field name from No to Num (or any non-reserved word).

No is a reserved Access/VBA/Jet word and should not be used as a
field name.

Also, as written, the where clause is expecting that the datatype of
the No field is a Number, not text. Is that correct?

For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'
 

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