Please help with a Do/Loop

T

TeeSee

I would like to be able to loob back to the InputBox when the user
(Me! at the moment) keys a number equal to or larger than 1. I am
getting the LOOP withou DO error. Could someone please set me straight
with my logic or lack thereof. If I input the correct less than 1
value the code sails thru.Thanks


Do While sglDiscount >= 1
strMessage = "Please input the new discount as a decimal"
Title = "Discount Update"
strInput = InputBox(strMessage, strTitle, Default, 5000,
3000)


sglDiscount = Val(strInput)

Debug.Print sglDiscount
If sglDiscount >= 1 Then
intResponse = MsgBox("Please input as a decimal as
asked!", vbOK + vbCritical, "WHOOOPS!")
End If
If intResponse = vbOK Then
Loop

Else
With rs
.MoveFirst
Do While Not .EOF
.Edit
!Discount = sglDiscount

.Update
.MoveNext
Loop
End With
End If
rs.Close
db.Close

Set rs = Nothing
Set db = Nothing

End Sub
 
J

Jeff Boyce

At what point in your code is this error occurring?

Add a breakpoint to your code and step through it to find the line that's
causing the error...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
T

TeeSee

At what point in your code is this error occurring?

Add a breakpoint to your code and step through it to find the line that's
causing the error...

Regards

Jeff Boyce
Microsoft Office/Access MVP













- Show quoted text -

Hi Jeff ... Thanks for responding.
When I compile the word LOOP is hi-lited.
Strangely as it may seem I am unable to STEP INTO/THRU any procedure
for some reason. May be you could offer a solution on that as well.

Best regards
 
J

Jeff Boyce

So, the application won't compile because Access/VBA believes the LOOP
statement has no DO before it...

Perhaps that's because the Loop statement is located inside an If...Then
statement?

Regards

Jeff Boyce
Microsoft Office/Access MVP

At what point in your code is this error occurring?

Add a breakpoint to your code and step through it to find the line that's
causing the error...

Regards

Jeff Boyce
Microsoft Office/Access MVP













- Show quoted text -

Hi Jeff ... Thanks for responding.
When I compile the word LOOP is hi-lited.
Strangely as it may seem I am unable to STEP INTO/THRU any procedure
for some reason. May be you could offer a solution on that as well.

Best regards
 

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