Report based on a record

B

blanch2010

How can I make a report, when it's opened, ask for user input?

I need to have the user select a name from a list & report on that name's
record.

Is this done in the query for the report or the report itself?

Thank You
Don
 
B

blanch2010

Private Sub cmdRunClientInvoice_Click()
Dim strDocName As String
Dim strWhere As String
strDocName = "rptBillingByClient"
strWhere = "[ClientID]=" & Me!ClientID
DoCmd.OpenReport strDocName, acPreview, , strWhere
End Sub

This gets me an error stating:

Run-time error '3079'
The specified field '[Client]' could refer to more than one table listed in
the From clause of your SQL statement.

I'm not sure what I'm doing wrong but I did, instead of [ClientID] use
ClientLastName and I get a parameter box that pops up asking for the client
lastname. Which, when I type in the client lastname, the reports opens
correctly.

All of this is being done on a form that is showing clientid &
client1lastname.

Any thoughts Duane, other then I'm all messed up?

Thanks again
Don
 
B

blanch2010

Private Sub cmdRunClientInvoice_Click()
Dim strDocName As String
Dim strWhere As String
strDocName = "rptBillingByClient"
strWhere = "[ClientID]=" & Me!ClientID
DoCmd.OpenReport strDocName, acPreview, , strWhere
End Sub

This gets me an error stating:

Run-time error '3079'
The specified field '[ClientID]' could refer to more than one table listed in
the From clause of your SQL statement.

I'm not sure what I'm doing wrong but I did, instead of [ClientID] use
ClientLastName and I get a parameter box that pops up asking for a specific
client
lastname. Which, when I type in the client lastname, the reports opens
correctly.

All of this is being done on a form that is showing two combo boxes:
clientid &
client1lastname.

Any thoughts Duane, other then I'm all messed up?

Thanks again
Don
 
D

Duane Hookom

I expect you have a report record source that might use the "*" to select all
fields. This is generally a bad idea. You should explicitly identify/select
individual fields from at least some of the tables.

Also, if you use a criteria agains a text field, you must add some quotes:
strWhere = "[TextFieldName]=""" & Me!txtTextField & """ "
 
B

blanch2010

Thank you very much Duane. It's working perfectly.

Don


Duane Hookom said:
I expect you have a report record source that might use the "*" to select all
fields. This is generally a bad idea. You should explicitly identify/select
individual fields from at least some of the tables.

Also, if you use a criteria agains a text field, you must add some quotes:
strWhere = "[TextFieldName]=""" & Me!txtTextField & """ "

--
Duane Hookom
Microsoft Access MVP


blanch2010 said:
Private Sub cmdRunClientInvoice_Click()
Dim strDocName As String
Dim strWhere As String
strDocName = "rptBillingByClient"
strWhere = "[ClientID]=" & Me!ClientID
DoCmd.OpenReport strDocName, acPreview, , strWhere
End Sub

This gets me an error stating:

Run-time error '3079'
The specified field '[ClientID]' could refer to more than one table listed in
the From clause of your SQL statement.

I'm not sure what I'm doing wrong but I did, instead of [ClientID] use
ClientLastName and I get a parameter box that pops up asking for a specific
client
lastname. Which, when I type in the client lastname, the reports opens
correctly.

All of this is being done on a form that is showing two combo boxes:
clientid &
client1lastname.

Any thoughts Duane, other then I'm all messed up?

Thanks again
Don
 

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