This is kind of a continuation of the last problem I had but it's slightly different. Here is the code i have so far
Private Sub Report_Open(Cancel As Integer)
Me.Filter = "SAE=" & Me.OpenArgs
Me.FilterOn = True
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM [SAE]", dbOpenDynaset)
msgtitle = ""
msgbody = ""
MyPath = "G:\Jason\Blueline\"
Do Until rst.EOF
saename = rst.Fields(1).Value
saeemail = rst.Fields(2).Value
MyFilename = "Blueline Report - " & saename
DoCmd.OpenReport "WIP", acViewPreview, , , , saename
DoCmd.OutputTo acOutputReport, "WIP", acFormatPDF, MyPath & MyFilename, True
DoCmd.SendObject acSendReport, "WIP", acFormatPDF, saeemail, , , msgtitle, msgbody, False
DoCmd.Close acReport, "WIP"
The yellow line is where I believe I am having a problem. What I am doing is cycling through a list of names, opening a report based on that name/filtering for that name in the query, saving it to my hard disc and then emailing it out. I need this to be automated with no popups as I will be distributing 200+ reports. Currently as this code stands, I keep receiving a popup for the saename. It keeps displaying the value, lets say jason, as a parameter and asks me to enter a value. I don't know if this is by design but from what I understood, it should just pass the argument on to the on open event for the report and filter for that. I'm not sure what I could be doing wrong. Any ideas? Also I was curious if I am able to have a space or a comma in the argument. I tried Jason Doe and Doe, Jason and got an error. When I use just the first name I don't get an error but i get the parameter popup for the first name.