Re: Would like to loop
- From: TeeSee <bkeanie@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 16 Jan 2009 16:19:23 -0800 (PST)
On Jan 16, 6:43 pm, John W. Vinson
<jvinson@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
On Fri, 16 Jan 2009 15:26:50 -0800 (PST), TeeSee <bkea...@xxxxxxxxxxxxxxxxxxxx>
wrote:
Would someone please offer a solution to loop through the following
code for as many times as there are records in "rs"
The code compiles and it loops through it all but only updates the
first record. I can't get my head around the loop logic.
MsA 2003 and XP only Thanks for any help!
intCount = 1
With rsListHist
For intCount = 1 To rs.RecordCount
.MoveFirst
Do While intCount <= rs.RecordCount
Debug.Print Me.SISItemCode
rsListHist.AddNew
rsListHist!FieldName = strCtl
rsListHist!UserName = CurrentUser()
rsListHist!SISItemCode = SISItemCode
rsListHist!ChngeDate = Now()
rsListHist!OldDiscount = Discount.OldValue
rsListHist!NewDiscount = intDiscount
rsListHist!ControlSource = ctlSource
rsListHist.Update
.MoveNext
Loop
End With
Next
Erm?
Avoid the entire problem by using an Append query rather than looping through
a recordset. You're looping through rs but - as far as I can tell - never
doing anything with the records in it. What is rs, what is the context, and
why are you (apparently) trying to create rs.recordcount identical records in
reListHist?
--
John W. Vinson [MVP]- Hide quoted text -
- Show quoted text -
John ... Thanks for responding.
Company ABC sells to me with a list price less a discount which can be
for few or many records. Same discount for all. So depending on the
item(s) I create a recordset "rs" with the records I want to change.
Since there can be 1 or 20 or 100 records I first show the content in
"rs" in a form in order that I can verify the records prior to
updating them all. Before I actually do the update I am trying to
write the changes and the source etc as shown in the code in the post.
There is further code below this that also runs through the 'rs"
recordset and updates it. I didn't show that since I felt that if I
could get the looping logic correct I'd be off to the races. Obviously
my approach is flawed. Any help to improve understanding is always
welcome.
Best rgards
.
- Follow-Ups:
- Re: Would like to loop
- From: George Hepworth
- Re: Would like to loop
- From: John W . Vinson
- Re: Would like to loop
- References:
- Would like to loop
- From: TeeSee
- Re: Would like to loop
- From: John W . Vinson
- Would like to loop
- Prev by Date: Re: Would like to loop
- Next by Date: Re: Would like to loop
- Previous by thread: Re: Would like to loop
- Next by thread: Re: Would like to loop
- Index(es):
Relevant Pages
|