Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    117

    Unanswered: Setting Recordset values to a variable

    Hello sir,
    I am havign recordset created in MS-Access having "no1" field with different datas.

    I want all that values to set to a only one variable

    Pls do help me in this coding

    Thank you sir.

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Perhaps posting a sample of how the data looks and what you want out of it will help.
    Paul

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I'm "guessing" what you're trying to do involves looping through the recordset and storing the values in a string variable. ie...

    (something like this but you'll need to tweak - I did this quickly....)
    Dim rs as adodb.recordset
    set rs = new adodb.recordset
    dim strSQL as string
    dim MyVariable as variant
    strSQL = "Select no1 from MyTable"
    rs.open strsql,currentproject.connection,adopenkeyset,adlo ckreadonly
    rs.movefirst
    MyVariable = rs!no1
    rs.movenext
    do while not rs.eof
    MyVariable = MyVariable & ";" & rs!no1 (use whatever you want to separate versus a ; )
    rs.movenext
    loop
    rs.close
    set rs = nothing
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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