Opening report with command button

J

JeanetteJH

I am working on a Inventory database and I have a Purchase Requistion form
that I would like to turn into a report using a command button on the form
for the current record on the form. This form is based on a Purchase
Requsition table and also contains a subform from an Inventory Transacations
query that includes items that I want to order & I want this report to
actually be a Purchase Requistion that can be printed for approval. The form
seems to work fine, and I am using the following code for the command button,
but I keep getting an error that says "The Microsoft Office Access database
engine could not find the object 'PurchaseReqID = 17'. Make sure the object
exists and that you spell its name and the path name correctly.

Private Sub Preview_Purchase_Requisition_Click()
On Error GoTo Err_Preview_Purchase_Requisition_Click

Dim stReportName As String
Dim stLinkCriteria As String

If Me.Dirty Then Me.Dirty = False 'saves any changes

stReportName = "rptPurchase Order"

stLinkCriteria = "PurchaseReqID = " & Me!PurchaseReqID
DoCmd.OpenReport stReportName, acPreview, stLinkCriteria

Exit_Preview_Purchase_Requisition_Click:
Exit Sub

Err_Preview_Purchase_Requisition_Click:
MsgBox Err.Description
Resume Exit_Preview_Purchase_Requisition_Click
End Sub


Can anyone tell me what I am doing wrong?

Thanks for any help
Jeanette
 
M

Marshall Barton

JeanetteJH said:
I am working on a Inventory database and I have a Purchase Requistion form
that I would like to turn into a report using a command button on the form
for the current record on the form. This form is based on a Purchase
Requsition table and also contains a subform from an Inventory Transacations
query that includes items that I want to order & I want this report to
actually be a Purchase Requistion that can be printed for approval. The form
seems to work fine, and I am using the following code for the command button,
but I keep getting an error that says "The Microsoft Office Access database
engine could not find the object 'PurchaseReqID = 17'. Make sure the object
exists and that you spell its name and the path name correctly.

Private Sub Preview_Purchase_Requisition_Click()
On Error GoTo Err_Preview_Purchase_Requisition_Click

Dim stReportName As String
Dim stLinkCriteria As String

If Me.Dirty Then Me.Dirty = False 'saves any changes

stReportName = "rptPurchase Order"

stLinkCriteria = "PurchaseReqID = " & Me!PurchaseReqID
DoCmd.OpenReport stReportName, acPreview, stLinkCriteria


You need another comma before stLinkCriteria
 
J

JeanetteJH

Thank you!


Marshall said:
I am working on a Inventory database and I have a Purchase Requistion form
that I would like to turn into a report using a command button on the form
[quoted text clipped - 19 lines]
stLinkCriteria = "PurchaseReqID = " & Me!PurchaseReqID
DoCmd.OpenReport stReportName, acPreview, stLinkCriteria

You need another comma before stLinkCriteria
 

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