×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Record set looping

Record set looping

Record set looping

(OP)
I'm trying to loop through a table records and fields. The field loops work fine, but I can't get it to move down to the next "tbl" record..


i'm using 3 record sets all based on the same table
tbl = the set I want to loop through
rst1 = loops through table field names and compares against rst2
rst2 = loops through table field names


CODE -->

tbl.MoveFirst
        Do While Not tbl.EOF
            If tbl!ID_Vessel = OldVesID And tbl!Est_ID = OldEst Then
                With rst1
                    .AddNew
                    !ID_Vessel = NewVesID
                    !Est_ID = NewEst
                    For Each fld1 In rst1.Fields
                        If fld1.Name <> "ID" And fld1.Name <> "ID_Vessel" And fld1.Name <> "Est_ID" Then
                            For Each fld2 In rst2.Fields
                                If fld1.Name = fld2.Name Then
                                    If IsFieldCalculated(tblName, fld2.Name) <> True Then
                                        fld1 = fld2
                                    End If
                                End If
                            Next fld2
                        End If
                    Next fld1
                    .Update
                    .Close
                End With
            End If
            tbl.MoveNext
        Loop 


I was thinking that maybe an SQL statement would work with to copy and paste if ID_Vessel = OldVesID AND Est_ID - OldEst... but i'm not sure how i could replace only the copied ID_Vessel & Est_ID with NewVesID & NewEst. or maybe some other nice and easy way.

RE: Record set looping

Can you post the file with sample data? I'm not even sure if you are using access or excel here.

RE: Record set looping

Hi,

Not sure why you're using 3 recordset representation on 1 table.

I've always used just 1.

So I need to understand what you're trying to do functionally.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Record set looping

(OP)
here are the record set explanations.

tbl = i'm going through the table row by row looking for ID_Vessel and Est_ID

if the row meets the criteria then
rst1 = goes through the column header names one at a time and compares them to rst2
rst2 = goes through the column header names within rst1, and compares them to rst1

it rst1 fld1.name = rst2 fld2.name, then I copy rst1 fld1 value and put it into rst2's fld2 value, where fld = field

basically i'm trying to copy a record that has some fields that you can't copy.. like calculated fields, autonumber, things like that.. and have it dynamic so I feed it a table name and it doesn't care what type of field they are or how many fields.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close