Loop

  • Thread starter EMILYTAN via AccessMonster.com
  • Start date
E

EMILYTAN via AccessMonster.com

Is there any way, where u you select the record (part number, quantity)
where the order number = strOrderNum...

Then,
I will put a loop there to do until it end.
But just the moment entering the loop, i will need to check whether this
selected part number exists in that table under the specified job number...
If exists, will update accumulate the quantity else it will insert a new line.
..

How should I do it?
 
S

SusanV

Open an ADODB.recordset with that record as criteria, and set the loop under
an IF statement:

If recordset.recordcount > 0 then
'do whatever in your loop
end if

For example, I use a loop in an if records exist here:

strSQL = "SELECT [TMINS #],TMTitle from tblTMTemp WHERE [TMINS #] is
null"
rst.Open strSQL, cnx, adOpenKeyset, adLockOptimistic
If rst.RecordCount > 0 Then
rst.MoveFirst
Do While Not rst.EOF
n = n + 1
strTM = strClass & " NoTM No." & n
rst![TMINS #] = strTM
rst.Update
rst.MoveNext
Loop
End If
 
S

SusanV

By the way this is done in a VBA function or sub, not in a query... sorry if
I confused you!

--
hth,
SusanV


SusanV said:
Open an ADODB.recordset with that record as criteria, and set the loop
under an IF statement:

If recordset.recordcount > 0 then
'do whatever in your loop
end if

For example, I use a loop in an if records exist here:

strSQL = "SELECT [TMINS #],TMTitle from tblTMTemp WHERE [TMINS #] is
null"
rst.Open strSQL, cnx, adOpenKeyset, adLockOptimistic
If rst.RecordCount > 0 Then
rst.MoveFirst
Do While Not rst.EOF
n = n + 1
strTM = strClass & " NoTM No." & n
rst![TMINS #] = strTM
rst.Update
rst.MoveNext
Loop
End If
 

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