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 
This stumped everyone
Kevin Yip 
     
4 years ago
Hi Richard, you may consider making a video for this.  It's a simple problem that stumped everyone at another forum I just saw.  

On a form, there are two text boxes with *calculated* numeric values as their control sources. Let say one has "=4/4", which equals to one, and another has "=2*5" which equals to 10. There is another text box for user entry. If the entry is outside the range of the two calculated fields, the user gets an error message.  So a BeforeUpdate event procedure is made:

Private Sub UserEntry_BeforeUpdate(Cancel As Integer)
    If Me!UserEntry < Me!CalcF1 Or Me!UserEntry > Me!CalcF2 Then
        MsgBox "Out of range."
        Cancel = True
    End If
End Sub

And yet, when the user enters 5, which is in range (between 1 and 10), he still gets the "out of range" error.

It turns out the UserEntry is treated as a STRING, and that's why the comparison doesn't work.

UserEntry must be converted to numeric. For instance: If Val(Me!UserEntry)< ...

Here is the forum thread where I saw this:
https://www.accessforums.net/showthread.php?t=85869

It's an interesting, simple, yet important little issue that your students may benefit from.

Richard Rost  @Reply  
          
4 years ago
Indeed! I go through this example in my VB 6 class, because pretty much ALL fields are treated as text, so you have to use the Val() function. But this would definitely make a good tip video. Thanks for the idea.

I just recently ran across this issue myself because I import my daily sales from Paypal. They come via CSV file that I download, and the "CustID" field imports as text. To join it to my CustomerID field (Long) I have to CLng it to convert it to long. I was thinking of making a video about that too. Maybe I'll combine them.

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: 4/30/2026 2:11:47 PM. PLT: 1s