Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Looped IF statements
Larry Martino 
     
2 years ago
In my form I have multiple IF statements to evaluate criteria on the form.  I have been able to loop 12 If statements to evaluate multiple scenarios however when I loop in more that are similar the evaluation stops.  I am wondering if the IF statements because only one value changes does it stop because it has done this process already.

See the attached string.

DetailsIf Modelnumbercombo.Column(2) = "3" Then
MsgBox "Only Good for SOP"
Else

If Modelnumbercombo.Column(2) = "19" Then
MsgBox "Only Good for Dose Rates"
Else

If Modelnumbercombo.Column(2) = "2360" Then
    If [Net CPM] >= [Text44] Then

MsgBox "Take out of service"
Else
If Modelnumbercombo.Column(2) = "2360" Then
    If [Net CPM] <= [Source -3 Sigma] Then

MsgBox "Take out of service immediately "
Else

If Modelnumbercombo.Column(2) = "2360" Then
    If [Net CPM] <= [Source -2 Sigma] Then
    
    MsgBox "Not OK For FSS, but OK for General Use"
Else

If Modelnumbercombo.Column(2) = "2360" Then
    If [Net CPM] >= [Text42] Then
    
    MsgBox "Not OK For FSS, but OK for General Use"
Else

If Modelnumbercombo.Column(2) = "2360" Then
    If [Net CPM] >= [Source -2 Sigma] Then

MsgBox "Ok for FSS"
Else

If Modelnumbercombo.Column(2) = "3003" Then
    If [Net CPM] >= [Text44] Then

MsgBox "Take out of service"
Else
If Modelnumbercombo.Column(2) = "3003" Then
    If [Net CPM] <= [Source -3 Sigma] Then

MsgBox "Take out of service immediately "
Else

If Modelnumbercombo.Column(2) = "3003" Then
    If [Net CPM] <= [Source -2 Sigma] Then
    
    MsgBox "Not OK For FSS, but OK for General Use"
Else

If Modelnumbercombo.Column(2) = "3003" Then
    If [Net CPM] >= [Text42] Then
    
    MsgBox "Not OK For FSS, but OK for General Use"
Else

If Modelnumbercombo.Column(2) = "3003" Then
    If [Net CPM] >= [Source -2 Sigma] Then

MsgBox "Ok for FSS"
MsgBox "Nice Try"

End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Kevin Robertson  @Reply  
          
2 years ago
I think you mean nested, not looped.
Sami Shamma  @Reply  
             
2 years ago
use "Select Case"
Watch this video:
Select Case
Kevin Yip  @Reply  
     
2 years ago
Hi Larry, if you write "If A Then B Else C", then either B or C will be run, not both.  So you need to place the Else keyword carefully.  

Also, if you write "If A >= B Then C ElseIf A <= B Then D", then if A *equals* B, only C will run, not D.  This is another instance where something you think will run, won't.  In this case you need to check If A = B separately.

Thirdly, you don't need nesting if the condition is the same for everything below it.  Everything under Modelnumbercombo.Column(2) = "2360" can be put inside one If/End If block, as shown below.  Same for Modelnumbercombo.Column(2) = "3003".  Also consider using ElseIf (one word) instead of Else...If.

If Modelnumbercombo.Column(2) = "2360" Then
    If A >= B Then
    ...
    ElseIf C <= D Then
    ...
    End If
End If
Larry Martino OP  @Reply  
     
2 years ago
Thank you all good points.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/7/2026 4:56:01 AM. PLT: 0s