Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report based on a recorset

Status
Not open for further replies.

Richey

Technical User
Aug 29, 2000
121
GB
Hi
I'm trying to base a report on a recordset activated from a form
I'm using the code below, where list18 is a list box on a form. I'm trying to build up the string and then say, send the report target_action_sheet by email based on the recordset. Any ideas much appreciated?
Richey

Dim dbs As Database
Dim str As String
Dim strsql As String
Dim strsql1 As String
Dim rst As Recordset

Set dbs = CurrentDb

str = "SELECT * from target_action_sheet where audit_no=" & Me![List18]
Msgbox (str)
Set rst = dbs.OpenRecordset(str)
strsql = "SELECT responsible from target_action_sheet where recommendation_number =" & rst("recommendation_number")
Msgbox (strsql)
Set rst = dbs.OpenRecordset(strsql)
strsql1 = "SELECT email from tblresponsible where responsible=" & "'" & rst("responsible") & "'"
Set rst = dbs.OpenRecordset(strsql1)
With rst
Msgbox (strsql1)
DoCmd.SendObject acSendReport, "target_action_sheet", acFormatXLS, rst.Fields(0), , , , , False
End With
rst.Close
Set dbs = Nothing
 
I usually create a query which my report is based on.
Then I add the Forms!.... to make the query only show records I have on my form.
Then create a command button on the form which E-mials the report.
When the report is opened (or sent by e-mail) it will be only the records based on the query and your form.
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top