Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2004
    Posts
    5

    Unanswered: storing SQL result into a VB variable?

    Here's my question, I am using a button to peform the following event code,
    basically I am trying to store the result of a quiery into a VB variable for
    later use... how can this be done?? any help is thanked in advance again!

    Dim MyVariable As String

    MyVariable = DoCmd.RunSQL "SELECT Name FROM createNeweDLPIRecord WHERE
    id=1434;"

  2. #2
    Join Date
    May 2004
    Posts
    97
    Because I goofed.

  3. #3
    Join Date
    May 2004
    Posts
    97
    A sql statement will always return a recordset. Even if it has only one record and one column it is still a recordset. Get the information into the variable the same way you would if you wanted the first record, first column.

  4. #4
    Join Date
    Nov 2004
    Posts
    108

    Exclamation ADODB.Recordset

    use the recordset

    Code:
    dim rec as new adodb.recordset
    rec.open sqlStatement,conn
    if you are not going to make any updates to the data you retrieve then
    make it a disconnected recordset

    Code:
    set conn = 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
  •