Filtering from a Subform

P

Pete Klein

Hello,
I have been killing myself trying to get this to work. I have a relational
database and I have created a main form with a subform and within that
subform, another subform. The main form is the client contact information and
the CustomerID. This is linked to the PurchaseOrder table that uses POnbr as
it's primary key. Then the parts table is linked to the PurchaseOrder table
by the PONbr. I am trying to print the customer information, PurchaseOrder
information and the Parts information on one report. Now I want to create a
command button that will allow me to choose a particular PO number and print
all the PurchaseOrder and parts information for that PO. I cannot get my
command button to filter the PO number and open the report in preview mode.
Please provide any information that you can to give me some help or direction
on this. Many hours spent trying with no results.

THANK YOU!
Pete
 
S

Sprinks

Pete,

You raise many issues. I think your fastest road to your goal is to study
the Northwind database supplied with Access. Choose Help, Sample Databases,
Northwind from the menus in the database window.

Good luck.

HTH
Sprinks
 
P

Pete Klein

Thanks Sprinks,

I just realized that I didn't mention something. I CAN get the report to
preview and I do get information. I just get ALL of the information. The
filter code in the command button is not working. Now I did place some
msgbox's in the code to make sure that I am isolating the proper filter data,
(i.e. the correct PONbr, etc for filtering), but when the report previews,
it's as if the filter was ignored. I don't know if this information makes a
difference in your advice but I thought I would throw it out there and see.

Thanks again,

Pete
 
P

Pete Klein

Sprinks,

Here is the command botton code that you requested. Thanks again.

Private Sub PurchaseOrderButton_Click()
DoCmd.SetWarnings False

Dim strDocName1 As String
Dim strFilter As String
strDocName1 = "PurchaseOrder"
strFilter = "PO# = Forms!PurchaseOrderForm!PO#"
DoCmd.OpenReport strDocName1, acPreview, strFilter

End Sub

Pete
 
S

Sprinks

Hi, Pete.

In your assignment of the filter, you really need a reference to the PO#
control on your form. With quotes around the entire string, it is just a
literal. It's also good practice to delimint Access objects with brackets.
Try:

strFilter = "[PO#] = " & Forms![PurchaseOrderForm]![PO#]

Hope that helps.
Sprinks
 
P

Pete Klein

Thank you Sprinks, I will give this a try.

Pete

Sprinks said:
Hi, Pete.

In your assignment of the filter, you really need a reference to the PO#
control on your form. With quotes around the entire string, it is just a
literal. It's also good practice to delimint Access objects with brackets.
Try:

strFilter = "[PO#] = " & Forms![PurchaseOrderForm]![PO#]

Hope that helps.
Sprinks


Pete Klein said:
Sprinks,

Here is the command botton code that you requested. Thanks again.

Private Sub PurchaseOrderButton_Click()
DoCmd.SetWarnings False

Dim strDocName1 As String
Dim strFilter As String
strDocName1 = "PurchaseOrder"
strFilter = "PO# = Forms!PurchaseOrderForm!PO#"
DoCmd.OpenReport strDocName1, acPreview, strFilter

End Sub

Pete
 

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