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 
Dlookup in Tables
Chris Tyson 
       
12 months ago
Is it advisable to put a dlookup value, from a query, as a default value in a table?
Sami Shamma  @Reply  
             
12 months ago
Chris, why do you want to put that default value in the table, not in a form?
Can you explain further what you are trying to do?
Thomas Gonder  @Reply  
      
12 months ago
Chris I see two potential problems with the question (but I realize I don't have enough information about your specific situation).
1) Unless the value that you're retrieving from another TABLE is an ID, then you shouldn't be bypassing the normalization of your tables.
2) Why go to a query for the DLookup (I've never tried) when it would be faster and clearer to go straight to the source table? I realize that some expressions might not work in the table's default.

Finally, although I do put some defaults into tables for fields that aren't expressly set in a form, I generally think that forms should be getting their defaults via VBA code. This allows for "intelligence" in the defaults. For example, in my Entity form, if you combo box select "Male" for the "Birth sex" control, then the default for "Gender identity" is "Man". If you keep that, or any other gender identity that is man oriented, then the default the "Name title" is "Mr.".
Thomas Gonder  @Reply  
      
12 months ago

Thomas Gonder  @Reply  
      
12 months ago

Thomas Gonder  @Reply  
      
12 months ago

Thomas Gonder  @Reply  
      
12 months ago

Thomas Gonder  @Reply  
      
12 months ago
There, I did all the design work for you. Well, one field anyways.
Chris Tyson OP  @Reply  
       
12 months ago
Thomas I really appreciate your  comments, but you are way over my head. I’m at the 1+1=2 level and you’re at the quadratic equation level.

Very basically, I’m using a query to calculate a future date based on a job end date and comparing that date to where it falls within an insurance policy year. I then have to add a certain number of years to the current policy end date to see how long I have to provide insurance for the job once we are finished. I have created a query to do that, probably more complicated than it needs to be,, and I can then  dlookup that value and show it in my form.

Sami:  I wanted to set that date value from the query into the tables field. There is probably a simple VBA solution to this, but I don’t know enough yet to do such a thing.

I am going to take a few days off so I may not be able to respond to any other comments for a few days.

Any guidance will be appreciated.
Thomas Gonder  @Reply  
      
12 months ago
Yes, it can get complicated. At some point your app may need something like this for a whole host of defaults.

My suggestion is to write, or get Sami to do it, a VBA procedure that does the calculation. then you can call that function in either queries or your form. That approach is immensely more efficient than using a query. At least you know the formula if your query works, so all isn't lost.

The thing to keep in mind, if I remember correctly, the defaults for Access forms are propagated to the fields the minute it goes dirty. If a calculation is required based on other entry controls in the form, you'll need VBA to calculate the default after update of the source entry control(s) or on got focus for the calculated entry control if it's Null.

If you want to learn, I suggest starting with Richad's VBA video, he mentions it in lots of videos. If not in that video, I'm sure he has one that tackles this kind of calculation for a default value. One of the moderators (this is right up Kevin R's alley) can probably provide the links.

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: 5/2/2026 8:54:19 AM. PLT: 1s