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 
Data Type Mismatch
Kim Wong 
     
16 months ago
I have declared a public variable as Integer, and this variable is used as a criteria in a query.  The definition of the variable matches the data type of the field in the table. Appreciate if anyone can help. Attached are details of my setup
Kim Wong OP  @Reply  
     
16 months ago

Sami Shamma  @Reply  
             
16 months ago
try to declare it as "Long"
Kevin Robertson  @Reply  
           
16 months ago
You can't use a Public variable in the the criteria of a Query like that. Use TempVars instead.

Example
Set the value

    TempVars("OldContractID") = 5

In the criteria of your Query field
    =TempVars!OldContractID
Kim Wong OP  @Reply  
     
16 months ago
Thanks Sami for your prompt response.  I have tried all data types including long and its still having the same error.

I am right watching Richard's video on TermVars and I think I know what the problem is.  In his video he says public variables cannot be used in queries, which is what I did in my query.  I am going to try using TempVars.  Let you know how it goes
Kim Wong OP  @Reply  
     
16 months ago
Thanks Kevin.  Onto it...
Sami Shamma  @Reply  
             
16 months ago
follow Kevin's advice
Kim Wong OP  @Reply  
     
16 months ago
Yup...TempVars worked! Thanks for all of your help,   And the coding Kevin...Saved me some time, and errors along the way.

Richard - your videos are gems! Thank you!

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/8/2026 6:16:00 AM. PLT: 1s