Re: Would like to loop

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
.



Relevant Pages

  • Re: WIA and hibernation again
    ... John John - MVP wrote: ... Could be this service is looking for updates for viewpoint products and thusly not allowing hibernation. ... Remote Access Connection Manager ... Windows Audio ...
    (microsoft.public.windowsxp.basics)
  • Re: Pack 2 Setup could not backup registry
    ... You won't be able to install SP2 until you've ... removed all traces of spyware/hijackware/malware from your system, John. ... Dealing with Trojans & Hijackware ... CWShredder v1.59.1 (no updates available currently; ...
    (microsoft.public.windowsupdate)
  • Re: rnd(0)*X in Assembler?
    ... I did an analysis of what would happen if I used a Random Lookup ... rather than using a Random function that loops back if out of range. ... looping if you're out of range means sometimes a lot of what I consider ... plenty of computing time, it makes sense to generate a new Lookup Table, ...
    (comp.sys.cbm)
  • Re: Not forcing values to be equal
    ... ' Updates new Well Location record in frmWell_Parameters based on what ... "John W. Vinson" wrote: ...
    (microsoft.public.access.formscoding)
  • Re: KB960544 and KB957000 wont install
    ... You can simply hide the updates, ... John C wrote: ... Uninstall McAfee Security Center. ... install Vista SP1 via Windows Update, or did you choose to install SP1 ...
    (microsoft.public.windowsupdate)