Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2003
    Location
    USA
    Posts
    14

    Question Unanswered: Evaulate a query by code

    Does anyone know how I can evaluate a query while VBA code is executing. I have a series of queries evaluating information. Only upon completion of all information in one query do I want the code to continue. The value of the pivital query (if everthing works correctly) is null. does anyone know how I can write code that can evaluate when the query returns a null value in order to continue evaluating and processing data?

  2. #2
    Join Date
    Feb 2002
    Posts
    403
    you could feed the query into a recordset and test for records which should be 0.

    Using ADO this might look like:

    Dim rst as ADODB.recordset
    Dim strSQL as String

    strSQL=Your query

    set rst = New ADODB.recordset

    rst.open strSQL,CurrentProject.Connection,adOpenKeyset

    if rst.recordcount>0 then
    'Records are returned

    Else
    'Carry on no records returned

    End if

    rst.close

    Set rst=Nothing

  3. #3
    Join Date
    Apr 2003
    Location
    USA
    Posts
    14

    Smile Thank you

    I have been trying to come up with an evaluation for these queries. Thank you for your reply.

    Originally posted by dynamictiger
    you could feed the query into a recordset and test for records which should be 0.

    Using ADO this might look like:

    Dim rst as ADODB.recordset
    Dim strSQL as String

    strSQL=Your query

    set rst = New ADODB.recordset

    rst.open strSQL,CurrentProject.Connection,adOpenKeyset

    if rst.recordcount>0 then
    'Records are returned

    Else
    'Carry on no records returned

    End if

    rst.close

    Set rst=Nothing

Posting Permissions

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