Re: ADO Recordset Question
From: Brett S. (BrettS_at_discussions.microsoft.com)
Date: 02/02/05
- Next message: Melvis: "Re: Restoring a backed-up database using code"
- Previous message: Brooke Bournique: "Query uneditable due to pulling information from multiple tables"
- In reply to: Chris2: "Re: ADO Recordset Question"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 2 Feb 2005 07:29:11 -0800
Thanks Chris. This is very helpful. I also discovered last night how to
accomplish this task by using variables and putting them into a string of SQL
syntax to be exectued. However, this may be a cleaner way to accomplish this
task.
"Chris2" wrote:
>
> >
> > Brett S.,
> >
> > Aircode/Pseudocode ("With" block omitted for brevity), obviously
> > untested.
> >
> > Open Recordset1
> > Open Recordset2
> > rs1.MoveFirst
> > Do Until rs1.eof
> > rs2.AddNew
> > rs2.Fields("Emp_No") = rs1.Fields("Emp_No")
> > rs2.Fields("EventType") = rs1.Fields("EventType1")
> > rs2.Fields("EventType") = rs1.Fields("EventTypeDate1")
> > rs2.update
> > rs2.AddNew
> > rs2.Fields("Emp_No") = rs1.Fields("Emp_No")
> > rs2.Fields("EventType") = rs1.Fields("EventType2")
> > rs2.Fields("EventType") = rs1.Fields("EventTypeDate2")
> > rs2.update
> > etc.
> >
> > rs1.MoveNext
> > Loop
> > rs1.close
> > rs2.close
> > rs1 = nothing
> > rs2 = nothing
> > etc.
> >
> > If the number of columns involved in the de-normalized table is
> > excessive, then put the .AddNew/.Update segment inside a loop, put
> > string variables into the .Fields Properties of rs1,
> > "rs1.Fields(strColumnName)", and then change the names of the fields
> > programmatically via string manipulation, or even referrencing the
> > columns by number, if there's a controllable pattern.
> >
> >
> > Sincerely,
> >
> > Chris O.
> >
> >
>
> Yes, there is a typo, I forgot to change the EventType to EventDate in
> the third line of the .AddNew/.Update segments.
>
>
>
- Next message: Melvis: "Re: Restoring a backed-up database using code"
- Previous message: Brooke Bournique: "Query uneditable due to pulling information from multiple tables"
- In reply to: Chris2: "Re: ADO Recordset Question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|