Results 1 to 4 of 4
  1. #1
    Spidee is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    2

    Too few arguments is driving me crazy....


    Hi guys,

    I needed to srart tinkerring in Access/VBA/SQL trying to get some things done. I am reasonably sure I am doing things right, but access keeps on telling me, I am not giving it an argument it wants....any help?
    Thank you.

    Code:
     
        Dim newtest As String
        Dim newrs As DAO.Recordset
        Dim newfilter As String
        Dim rs2 As DAO.Recordset
        Dim asd As String
        newtest = "SELECT test.Helper_ID FROM test GROUP BY Test.Helper_ID"
        Set newrs = CurrentDb.OpenRecordset(newtest)
        Do Until newrs.EOF
            Debug.Print newrs![Helper_ID]
            asd = newrs![Helper_ID]
            newfilter = "SELECT Test.* FROM test WHERE helper_ID = asd"
    'this is where I fail....
            Set rs2 = CurrentDb.OpenRecordset(newfilter)
            
            newrs.MoveNext
        Loop

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I think

    Code:
    newfilter = "SELECT Test.* FROM test WHERE helper_ID = asd"
    should be

    Code:
    newfilter = "SELECT Test.* FROM test WHERE helper_ID ='" & asd & "'"
    It would help readers if you told/described to them WHAT exactly you are trying to do.

    You have dimmed asd as string, and usually (not alway) Ids are numeric. Is that what you intended?

  3. #3
    Spidee is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2013
    Posts
    2
    Orange,

    works like a charm! Thank you

    Apologies for not explaining what I wanted to do. The intention was:
    1. Get a listing of all Helper_ID, which are unique
    2. Select the first helper_id, filter on it (create a new recordset), go throught all the records and check if a bunch of conditions are met - if yes, do nothing, if no, add a new record in the original data set with values blablabla
    3. Move to next value of the helper_Id.

    Its just I still am learning the Syntax.
    Peter

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

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

Similar Threads

  1. I know it's easy but it's driving me crazy!!!
    By pensived in forum Queries
    Replies: 1
    Last Post: 02-22-2012, 02:55 AM
  2. Crazy Counting
    By gbharris in forum Queries
    Replies: 1
    Last Post: 08-31-2011, 03:07 PM
  3. ShipToCode is driving me crazy
    By Accessgrasshopper in forum Access
    Replies: 7
    Last Post: 02-26-2011, 04:55 PM
  4. Report issue driving me crazy
    By Grofica in forum Reports
    Replies: 11
    Last Post: 01-28-2011, 11:23 AM
  5. Autonumber gone crazy
    By asearle in forum Access
    Replies: 1
    Last Post: 07-27-2010, 05:41 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