Recently Maarten a blog reader asks: TempVars (introduced with Access 2007) are great,
Windows 7 License! But I have some problems in using them. I created a query with a TempVar as criteria. When I run the query it shows the correct data. But when I open the query in VBA using OpenRecordset,
Windows 7 Product Key, I get the message: “Run-time error 3061: Too few parameters. Expected 1.” This is the expected behavior. TempVars are defined in the scope of the Access Application object. When you use the CurrentDB.OpenRecordset method,
Microsoft Office Standard 2010, the resulting recordset is defined in the scope of the ACE database engine (DAO). Here is a workaround. Create and form based on the query and assign your recordset to it. Something like this… DoCmd.OpenForm "FormName", WindowMode:=acHidden
Set rs = Forms("FormName").Recordset ... Do stuff DoCmd.Close acForm,
Microsoft Office Professional Plus 2010, "FormName" Enjoy,
Office 2010 Professional Plus! <div