Run report, but restrict contents to current customer on my form

G

Guest

I've got a report that runs billing info on all customers (using a query, not
a table). I want a button on my customer form that will open the report in
preview mode, but with only that customer's info.

I did something similar years ago with an openform, but I'm not sure how I
came up with the code.
_________________________________________________________________

Private Sub CommandEngineDetail_Click()

On Error GoTo Err_CommandEngineDetail_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmEngine"

stLinkCriteria = "[EngineID]=" & Me![EngineID]
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_CommandEngineDetail_Click:
Exit Sub

Err_CommandEngineDetail_Click:
MsgBox Err.Description
Resume Exit_CommandEngineDetail_Click

End Sub

_____________________________________________________________

This button pulls up my engine form with a particular id (from a form that
has a list of all engines on it), or can be run standalone to just display
all engines down the index path. Which is what I want my billing report to
do. I want the CustomerID on my form and my CustomerID on the query to
match, and pull up only that customer.

I'm looking around on how to use OpenForm, but I'm not getting the gist.
Any help would be appreciated.

Clayton
 
G

Guest

Clay said:
I've got a report that runs billing info on all customers (using a query, not
a table). I want a button on my customer form that will open the report in
preview mode, but with only that customer's info.

Here is what I came up with, but it doesn't limit the report to just one
customer. I get a prompt asking me for the very thing I just limited it to -
BillingTimeQuarterly.CustomerID. Even if I answer that prompt with a '1', I
get results for everybody. If I leave it blank or enter an invalid customer
number, I get a report full of garbage data. So why am I not actually
passing a good idea to the report?

Private Sub Command65_Click()

On Error GoTo Err_Command65_Click

MsgBox "Begin"

Dim stDocName As String
Dim stLinkCriteria As String
Dim stFiltername As String

stDocName = "BeSeenOnTheInternet"
stFiltername = "BillingTimeQuarterly"

stLinkCriteria = "BillingTimeQuarterly.CustomerID=" & Form![CustomerID]

DoCmd.OpenReport stDocName, acViewPreview, stFiltername, stLinkCriteria
Exit Sub

Err_Command65_Click:
MsgBox Err.Description
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