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 Developer 3    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
03 For Next Loops 08402147
Stamatios Papoutsis 
    
3 years ago
Dear Richard,

We declared Dim Answer As Integer but if we select the Cancel option of the input box we get a zero length string as the value for the variable Answer so we get a type mismatch error.
I removed the Integer declaration and also added to the code that If Answer <>"" then run the code else exit sub.
Waiting for your thoughts and proposals!  

Best regards,

Stamatis Papoutsis-Greece
Kevin Robertson  @Reply  
          
3 years ago
Input Boxes always return a string.

Declare your variable as a String, you can always covert it to an Integer later if you need to use the value in calculations.
Stamatios Papoutsis OP  @Reply  
    
3 years ago
Dear Kevin,

For the specific exam of Richard's, if the Variable called Answer is set to Integer the code does not work if we enter a numeric value.
Scott Axton  @Reply  
        
3 years ago


Use the NZ Function to change a Null to 0
Stamatios Papoutsis OP  @Reply  
    
3 years ago
My bad,

I mean the code does not work if we don't enter a numeric value (i.e enter text or blank and press OK or just press cancel.
Stamatios Papoutsis OP  @Reply  
    
3 years ago
Dear Scott,

Thanks! The input box have two options right? One option is to enter a value and press OK or press OK WITHOUT a value. The second option is to CANCEL the program. In the first option I want the user to receive a warning message that he did not enter a value but in the second option I want the program to stop without any further dialog. I am wondering how to make the code understand from where the zero length string comes from (OK with blank or Cancel with blank)  in order to either print a warning message OR to exit the program.
Stamatios Papoutsis OP  @Reply  
    
3 years ago
I found the following solution which works well. The input box has a default prompt which will be returned in case the user press only the O.K button. If the user press the cancel button then a Zero length string will be returned therefore we can separate the two cases.
Stamatios Papoutsis OP  @Reply  
    
3 years ago

Kevin Robertson  @Reply  
          
3 years ago

Stamatios Papoutsis OP  @Reply  
    
3 years ago
Dear Kevin,
Thank you for your proposal. However, the proposed code cannot separate the action to be carried out depending on the user's intention to carry out the program by pressing OK but forgetting to enter a value and his decision to Cancel the program. Both OK with blank and the Cancel with blank just exit the sub without any warning in the case of O.K with Blank entry.

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

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: 4/30/2026 11:12:56 AM. PLT: 1s