Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    TempVars (Access 2007)

    I've created a query using 4 TempVar values as criteria. With the TemVars set the query works great. When I attempt to open a DAO.Recordset using the query, I get an error 3061, "Too few parameters, 4 expected." I then reran the query and it works just fine. I tried specifying each TempVars as a parameter in the query ... same results I can run the query, but can't open a recordset. There is something I'm overlooking, but ....?

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: TempVars (Access 2007)

    This a bit of a guess, but I expect that DAO does not know about TempVars.

    The solution would be to convert your query to an SQL statement where the references to tempvars are resolved within Access, and only the actual values passed onto DAO.

    this is an example of what I mean.

    strSQL = "SELECT Email_Address FROM tblPeople WHERE Branch_Code= " & TempVars("SelectedBranch").Value
    Regards
    John



  3. #3
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    Sacramento, CA
    Posts
    193
    Thanks
    3
    Thanked 1 Time in 1 Post

    Re: TempVars (Access 2007)

    Prior to getting 2007, that's the way I usually did it, but TempVars appeared to be a simple alternative. However you've given me a thought about trying ADO instead of DAO.

    Doesn't work in ADO either.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TempVars (Access 2007)

    Neither DAO nor ADO "know" anything about VBA variables, whether built-in, such as TempVars, or user-defined.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •