Do Until Loop help

A

Alex

ID Model# Part# NHL NHLNHL Qty
1 999 aaa Top 2
2 999 bbb aaa Top 4
3 999 ccc bbb aaa 5
4 999 ddd ccc bbb 2
5 999 eee bbb aaa 4

I'm trying to use Do Until...Loop the populate a field on a form called EAU.
I've been trying variations of the following code all day to no avail. What
I need is to populate the EAU field, for example for record 4 with the
quantities of all 'baby' Part#'s. So for record 4, EAU would be (((2*5) * 4)
* 2). Record 5 EAU would be 4*4. The following code is working, but it will
only loop once then stop. This is my first experience with Do Loop. Any
help would be appreciated. Thanks so much.

Private Sub New_Part_Qty_AfterUpdate()
Dim CurrPart As String
Dim LookupNHL As String
Dim LookupQty As Double
Dim EAUTemp As Double

EAUTemp = Me.New_Part_Qty
CurrPart = Me.New_Part_NHL

LookupQty = 0

Do Until CurrPart = "Top"

On Error GoTo FinishUp

LookupNHL = DLookup("[NHL]", "AllNewParts", "[Model#] = [Model#] And [Part#]
= '" & CurrPart & "' And [NHL] = [NHLNHLctr]")
LookupNHLNHL = DLookup("[NHLNHL]", "AllNewParts", "[Model#] = [Model#] And
[Part#] = '" & CurrPart & "' And [NHL] = [NHLNHLctr]")
LookupQty = DLookup("[Qty]", "AllNewParts", "[Model#] = [Model#] And [Part#]
= '" & CurrPart & "' And [NHL] = [NHLNHLctr]")

EAUTemp = Me.New_Part_EAU
EAUTemp = LookupQty * EAUTemp

Loop

FinishUp:
Me.New_Part_EAU = EAUTemp

End Sub
 
V

Vsn

as what i can see quickly; with in your do until ... look the valve of the
CurrPart is nowhere assigned or changing..... does that help?

Ludovic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top