Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2003
    Posts
    81

    Question Unanswered: Store qry Result

    Please Help
    Can I store the result of a query to a variable;

    I am trying this but...runtime error

    Set rsAverageDate = New ADODB.Recordset
    rsAverageDate.Open "SELECT qryAverageDate.AverageDate FROM qryAverageDate", CurrentProject.Connection, adOpenDynamic, adLockReadOnly
    MsgBox "Average Date: " & rsAverageDate!AverageDate

  2. #2
    Join Date
    Feb 2005
    Posts
    20
    which runtime error?

  3. #3
    Join Date
    Jul 2003
    Posts
    81

    Exclamation

    I get a runtime error "Invalid sql statement;expected SELECT, UPDATE,DELETE..."

    The query runs OK.

  4. #4
    Join Date
    Feb 2005
    Posts
    20
    the code should look like this:

    Dim rsaveragedate As New ADODB.Recordset
    rsaveragedate.Open "SELECT qryAverageDate.AverageDate FROM qryAverageDate", CurrentProject.Connection, adOpenDynamic, adLockReadOnly
    MsgBox "Average Date: " & rsaveragedate!AverageDate

  5. #5
    Join Date
    Jul 2003
    Posts
    81

    Thumbs up

    If I say:
    Dim rs as adodb.recordset
    and then
    set rs=new adodb.recordset

    is the same as the
    dim rs as new adodb.recordset

    so, this doesn't fix my problem

    But thanks for the try

Posting Permissions

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