Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Atlanta, Georgia, USA
    Posts
    274
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Recordset variables (2000)

    I'm trying to populate a table through code.
    The fields in tblFinal are User, Firstname, Lastname, OrgCode1, OrgCode2, ~ Orgcode10
    I know its nat a good table setup but I have to work with what they want.
    <pre>Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim rst1 As DAO.Recordset
    Dim x As Integer
    Dim strName As String

    Set db = CurrentDb
    Set rst = db.OpenRecordset("tblBatch", dbOpenDynaset)
    Set rst1 = db.OpenRecordset("tblFinal")

    x = 1
    Do While Not rst.EOF
    Do Until x = 10
    rst1.AddNew
    rst1!User = rst!User
    rst1!LastName = rst!LastName
    rst1!FirstName = rst!FirstName
    rst1!OrgCode & x = rst!orgcode
    rst1.Update
    x = x + 1
    Loop
    rst.MoveNext
    x = 1
    Loop
    rst1.Close
    rst.Close</pre>


    What is the correct syntax for the line:
    rst1!OrgCode & x = rst!orgcode
    so it selects the right column? The Orgcode & x throws an error. I need it to loop through all 10 OrgCode columns.
    Thanks,
    Scott

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Recordset variables (2000)

    Try:
    rst1("OrgCode" & x) = rst!orgcode

Posting Permissions

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