Results 1 to 7 of 7

Thread: VB code producing an error

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    5

    VB code producing an error

    Hi,

    I'm working on the following code: -

    Code:
    Dim test As Database
    Dim Rs As DAO.Recordset
    Dim Msg As String
    Dim bFlag As Boolean
    
    Set Rs = CurrentDb.OpenRecordset("query", dbOpenStatic, dbReadOnly, dbOptimisticValue)
    ...
    But I'm having trouble as it returns the Run Time error 3001 "Invalid Argument", the line of code that it doesn't like is -

    Code:
    Set Rs = CurrentDb.OpenRecordset("query", dbOpenDynaset, dbAppendOnly, dbOptimisticValue)
    Can anyone help with a way to solve this error please? Or a way around it without using OpenRecordset?

    I've been stuck trying to solve this error for 3 days now!

    Thanks
    Last edited by Wildster; Jun 25th, 2008 at 03:42 AM.

  2. #2
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: VB code producing an error

    Try without the last argument:
    Code:
    Set Rs = CurrentDb.OpenRecordset("query", dbOpenStatic, dbReadOnly)
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    5

    Re: VB code producing an error

    Thanks for the response, I've tried it but it still produces the same error. Cant see why at all. Is there anything else you can think of?

    Thanks

  4. #4
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: VB code producing an error

    How about this:
    Code:
    Set Rs = CurrentDb.OpenRecordset("query", dbOpenDynaset)
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    5

    Re: VB code producing an error

    Too few parameters: Expected 3 is the error I now get, so it needs 3 parts to the argument

  6. #6
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: VB code producing an error

    What is "query"?
    That error comes from the "query".
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  7. #7

    Thread Starter
    New Member
    Join Date
    Jun 2008
    Posts
    5

    Re: VB code producing an error

    Sorted it, it was the references!! Thanks for the help guys
    Last edited by Wildster; Jun 25th, 2008 at 03: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
  •  



Click Here to Expand Forum to Full Width