I previously received help with 'programatically opening an attachment without user input'. However, prior to that point the user enters parameters into a query to limit the record set. With danishani's help I was able to get the code below. But now I realize that the query I'm employing has two parameters that are controlled by two controls on a form that the user fills in (Year & Month). I thought I could use a snippet of VBA, but it looks like is it difficult crossing methodologies mid-stream. When I run the code I get a message about the query needing 2 parameters, which I assume are the two I have already set in the query designer: "[FORMS]![DateParmswMonths
]" and "[FORMS]![DateParmswMonths
]" I need help deciding which path to take.
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Const cstrQueryName = "QryHazMart"
'Const strTable = "HazMart"
Const strField = "10156Rpt" ' Attachment field in Table1
Set dbs = CurrentDb
'Set rst = dbs.OpenRecordset(strTable)
Set rst = dbs.OpenRecordset(cstrQueryName)
'rst.MoveNext ' Uncomment this line to go to the 2nd row in the Table.
OpenFirstAttachmentAsTempFile rst, strField