Results 1 to 12 of 12
  1. #1
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Simple openrecordset Question

    I haven't had a chance to use any DAO for several months. This seems quite simple, but I'm stuck.

    Here's what I have and I can't get past this.

    Code:
           Dim rst1 As Recordset, rst2 As Recordset
        
        Set rst1 = CurrentDb.OpenRecordset("SELECT * FROM tblStatementArchive WHERE Vendor_ID Is Null")
        Set rst2 = CurrentDb.OpenRecordset("qryStatement1_Archive")
    On rst1 I get this error 13 - Type Mismatch

    On rst2 I get this error 3061 - Too few parameters Expecting 2
    There are no parameters in this query. There's not even a WHERE clause.

    Both queries run normally. I'm stuck. Hope you can help.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    For the first, maybe
    Never mind. Was not paying attentionearlier. Not sure why you would get a data type error as long as vendorID is a field name in the table.

    For the second, I do not know. I just started a thread of my own because I am getting the same error but, I am using a parameterized query.
    Last edited by ItsMe; 04-04-2014 at 05:00 PM. Reason: comment not on point

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    What happens if you use

    Dim rst1 As DAO.Recordset, rst2 As DAO.Recordset

    Linq ;0)>

  4. #4
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Dear Linq,

    I tried that after reading a few online forums, but it did not recognize DAO.Recordset. I dunno, maybe I spelled it wrong. I'll get back to you Monday from work.

    I see you are a fellow Richmonder. Greetings.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Works for me with or without the DAO qualifier.

    Dynamic filter parameter will cause the 'too few parameters' error. See ItsMe's thread https://www.accessforums.net/program...dao-42878.html
    I am guessing you have 2 dynamic parameters in the query object.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I wish I knew what the difference between using the qualifier and not using the qualifier is. I know, in some circumstances, the only way I have been able to get my code to work was to use DAO.Recordset vs. Recordset. Could never distinguish what was different between the two approaches.

  7. #7
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    You can also get the "Too Few Parameters" error for misspelling something in your query. Since it can't find your misspelled word, it assumes then that it's supposed to be a parameter. But since you didn't set that parameters value it is considered missing.

  8. #8
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Quote Originally Posted by Paul H View Post
    I haven't had a chance to use any DAO for several months. This seems quite simple, but I'm stuck.

    Here's what I have and I can't get past this.

    Code:
           Dim rst1 As Recordset, rst2 As Recordset
        
        Set rst1 = CurrentDb.OpenRecordset("SELECT * FROM tblStatementArchive WHERE Vendor_ID Is Null")
        Set rst2 = CurrentDb.OpenRecordset("qryStatement1_Archive")
    On rst1 I get this error 13 - Type Mismatch

    On rst2 I get this error 3061 - Too few parameters Expecting 2
    There are no parameters in this query. There's not even a WHERE clause.

    Both queries run normally. I'm stuck. Hope you can help.
    For your first recordset, are you getting data from an Access database or another database server like MySQL, or MS SQL? You need to be careful about some of the data types in other RDBMS's. For example, Access can't see Microsoft SQL's BigInt, and Date fields will show up as TEXT fields instead of date/time.

    As for your second recordset, I'm willing to bet you've misspelled something in your query like I mentioned in my earlier post.

  9. #9
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591
    Thanks for all your replies. Here's mine.

    Using DAO.Recordset gives me "User defined type not defined" which I just discovered meant I did not have the DAO library referenced. This database started life in a very old version of Access. I checked it and no longer got the error.

    I'm digging into part 2 of this. I'm thinking it will be an equally simple fix.

  10. #10
    Paul H's Avatar
    Paul H is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Location
    Richmond, VA
    Posts
    591

    Part 2 - SNAPSHOT !

    OK, I do have two parameters in my query. All they do is populate two fields. I tried the Eval() function to no avail.
    My original was sans Eval(). My 2nd attempt was without the tick marks. Oh yes, tried with and without declaring my parameters. All the same. Finally I dropped snapshot into my function and poof, no more problem. I don't even know what snapshot is. Very frustrated to have gone to so much trouble.

    When I'm cooled down I'll read the link in the thread you fed me June or someone can explain what snapshot is and why it was necessary.

  11. #11
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I use the constant dbOpenSnapshot or the integer equivalent 4 to open a snapshot. Basically, you are getting a read only copy of the data retrieved. There are not any record locks implied when using snapshot. However, if data is changed in the table by another user after you open the dataset, you will not see the changes when you move to the record that was edited by the other user. Changes made after you retrieve your snapshot will not be reflected in your snapshot.

    If I am not going to do any edits, update, append methods I will open a snapshot to avoid locking records or having access attempt to lock records. I believe default is dbOpenDynaset. You can add stuff to it like dbOpenOptimistic or dbOpenPessimistic.

    , dbOpenDynaset + dbOpenPessimistic)

  12. #12
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    Paul, why don't you post the SQL of your stored query here. I think it will make much more sense to us all if we can see it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Simple question
    By blackstatic42 in forum Access
    Replies: 4
    Last Post: 07-22-2020, 08:50 AM
  2. If and Else - very simple question
    By tygereye in forum Access
    Replies: 38
    Last Post: 04-02-2014, 06:06 AM
  3. Simple question
    By M.West in forum Database Design
    Replies: 2
    Last Post: 08-16-2012, 12:41 AM
  4. Simple question
    By KenM in forum Queries
    Replies: 1
    Last Post: 11-10-2009, 03:32 PM
  5. Very simple question!
    By fiddley in forum Programming
    Replies: 2
    Last Post: 04-28-2009, 02:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums