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 
Access 2007 If Then Else If Statement
Ryan 

16 years ago
Hello
 I am trying to create a If Then Else If Statement That takes information from a text box and generates a piece of text in another text box (unbound) for example:

If TxtBox1 = <18.0 Then
 TxtBox2 = "Low"
Else If TxtBox1 = 18.0 Thru 20.0 Then
 TxtBox2 = "Good"
Else If TxtBox1 = > 20.0 Then
 TxtBox2 = "High"
End If

Not Sure What I Am Doing Wrong Here, But It Don't Matter What Number I Type In TxtBox1, TxtBox2 Always Shows "Low".

Any Information On This Would Be Helpful.

Thanks,
Ryan


Answer from Richard Rost:

Well, first of all "thru" isn't a valid word in VBA. Second, it's always better to get those text values into numeric variables. Try this instead:

Dim X as Double
X = CDbl(TextBox1)
If X < 18.0 then
  TextBox2 = "Low"
Elseif X >= 18.0 AND X < 20.0 then
  TextBox2 = "Good"
Else
  TextBox2 = "High"
End if

You don't need your last condition because it will catch everything 20.0 and up.

Hope this helps.

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/22/2026 5:40:55 PM. PLT: 1s