Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Lexington Park, Maryland, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using Variables to identify a field in recordset (Access 2000)

    I have a variable that is the name of a field in a table. I need to be able to use the variable in a recordset statement. See the following:

    Dim strParam(i) as String
    Dim i as Integer
    Dim j as Integer

    For i = 1 to 16
    j = i + 8

    strParam(i) = "SaveStudyParam" & i

    rcrdset2![strParam(i)].Value = strSaveStudyParam(j)
    next i


    This is not working. I have tried the following:
    rcrdset2![" & strParam(i) & "].Value = strSaveStudyParam(j)
    rcrdset2![ & strParam(i) & ].Value = strSaveStudyParam(j)



    Thanks
    Mike

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Using Variables to identify a field in recordset (Access 2000)

    Try
    <code>
    rcrdset2.Fields(strParam(i)).Value
    </code>
    or
    <code>
    rcrdset2(strParam(i)).Value
    </code>
    Fields is the default property of the Recordset object, so it can be omitted.

  3. #3
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Lexington Park, Maryland, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using Variables to identify a field in recordset (Access 2000)

    Hans,

    Once again that worked perfectly.

    Mike

Posting Permissions

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