Report Record Source

C

Chuck

I have a form based on a query with a combobox to select the ClientName and
then display all relevant information on the form. I would like to create a
report with information passed from the form to the report ( On the form
there is the client name, dates etc) that i would like to pass to the report.
The report is basically a form letter welcoming the new client and i would
also like to add a text box or memo field that the user updates to
personlized the letter. I'm thinking i need a cmd button that launches the
report. What would the VBA look like for that. thanks.
 
J

Jeff Boyce

Chuck

Take a look at Access HELP for the

DoCmd.OpenReport

command. Its syntax includes the ability to pass the report a filter or a
WHERE clause, which you would use to pass the report the ID of the record
shown in the form. Base the report on the table holding the data you wish
to print, and let the filter or WHERE clause limit it to the single record.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
C

Chuck

Jeff, ok thanks i'll review the OpenReport cmd, if i have to pass fields from
two different tables, do i base the report on the table(s) or do i have to
use a query?
 
J

Jeff Boyce

Chuck

You'll have a lot more flexibility if you create a query that returns the
row(s) you want, and base your report on that query.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
C

Chuck

Jeff, i have created the report and have added a cmd button on the form. The
form's record source is driven from a combo box. I am using the following
code but it producing an #error on my report. On the report i have a text box
with following
control source =[First_Name] & " " & [Last_Name]
I also added a text box called [Last_Name] to the form to see if that would
help but it didn't

When i dont fire the cmd button (just launch report) i get the correct info
on the report but its not filtered to just the 1 record source from the form.
please help.


Private Sub Preview_Letter_Click()
On Error GoTo Err_Preview_Letter_Click

Dim stDocName As String
Dim strWhere As String
strWhere = "[Last_Name]= '" & Me.Combo79 & "'"

stDocName = "rptIntroLetter"
DoCmd.OpenReport stDocName, acPreview, , strWhere

Exit_Preview_Letter_Click:
Exit Sub

Err_Preview_Letter_Click:
MsgBox Err.Description
Resume Exit_Preview_Letter_Click

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