Combine a Loop Statement and If Statement? 
Author Message
 Combine a Loop Statement and If Statement?

Is it possible to combine a Loop Statement and If Statement? If so please
advise!

I'm working in Access 97 in the code.

I need an input box to come up only when a certain criteria is met one field
[Prod Code], then the user can only answer Yes or No to the input box, which
put the answer into [Logo] field.

The Logo field is a Yes/No field.

If [Prod Code] = "bcard" then
[Logo] = Inputbox "Have you got the logo?".....
End if

The problem is if the user enters in the Input Box anything other than Yes
or No or they leave it blank, a runtime error comes up. The user doesn't
even know how to deal with runtime errors.

My aim is to create a loop statement so if the criteria isn't met, the
question keeps coming up.

Sara



Tue, 24 Dec 2002 03:00:00 GMT  
 Combine a Loop Statement and If Statement?

Hi Sara/Laura (?),

dim bOK as Boolean
dim sAnswer as string

bOK = False
do
    sAnswer = Inputbox "Have you got the logo?".....
    if sAnswer ="Yes" or sAnswer ="No" then
        [Logo] =sAnswer
        bOK = True
    else
        MsgBox "Please write Yes or No!"
    end if
loop until bOK

HTH!
Katharina



Tue, 24 Dec 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problem on combine select statement on access

2. Combining SQL statements

3. Combine 2 Fields SQL statement Possible ?

4. Need help with loop statement

5. Expected:line number or label or statement or end of statement

6. Looping with an SQL statement

7. Help...Loop Statements

8. Loop statement doesn't work right

9. running sql code record by record instead of statement by statement

10. With...End With statement bombing out in For...Next statement

11. Do ... Loop Statements

12. Do... Loop Statements

 

 
Powered by phpBB® Forum Software