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 Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Variable not defined error
Paul Olstad 
     
3 years ago
Solution found to mysterious variable not defined error in Google.
I was at wits end.  I modified the Holiday Card database slightly to add several Boolean fields to help indicate whether we sent a letter (in addition to the Xmas card) to a family, and if we received a letter.  My tables are called FamilyT instead of CustomerT, and CardHistoryT instead of ContactT.  I added Boolean fields SentLetter, GotLetter and NewUpdate to FamilyT.  I set the SentLetter field manually but I want to set the GotLetter field when I am updating the LastReceived field in my Card Mailing List (Customer List) form.
When I double-click the LastReceived field, it adds todays date to the LastReceived field, it sets field RecdThisYear to True, it sets a field called NewUpdate to True (Used as the criteria for the update and append queries for the FamilyT and CardHistoryT tables), and asks the question via a MsgBox("Did you receive a Christmas letter?", vbYesNo).  If the answer is yes, I have the statement GotLetter = True, then End If.
Further it refreshes and runs two queries, to update the LastRecieved field in the FamilyT and to append the date and message to the CardHistoryT using NewUpdate = True as the criteria.  Then sets NewUpdate to False, does a Requery, and exits.
The problem:  When I tried to execute the event, GotLetter got a compile error:  Variable not defined.
I checked the spelling, copied and pasted even changed the name to no avail.  Three other fields from CustomerT were parsed and updated without error.  If I commented out the statement GotLetter = True, everything worked correctly.  All fields in both tables were updated correctly and the date and message were appended to CardHistoryT.  I made certain GotLetter is a field in every query.
The solution came from a Google post that suggested I add me! in front of Gotletter.  I changed it to me!GotLetter = True and everything now works correctly.  However, I really dont understand why this was necessary for this one variable name.
Richard Rost  @Reply  
          
3 years ago
Do you have Option Explicit set?

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer 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 10:27:31 AM. PLT: 1s