Solved

control source and dlookup ?

Posted on 1998-12-30
3
435 Views
Last Modified: 2008-02-20
I have a field which is has a dlookup. This is in the control source. When that data is displayed, I also want it to go into the appropriate field in the table. If the dlookup is in the control source, how do I fix this?
0
Comment
Question by:darcam
3 Comments
 
LVL 3

Expert Comment

by:tcurtin
ID: 1972301
why do you want it to do a dlookup  and use the table if you are returning the value in either?
0
 
LVL 2

Accepted Solution

by:
Belz earned 50 total points
ID: 1972302
Remove the DLookup from the control source.  Attach the control source to the field you want data stored in.  Inside a code event add the DLookup code and store it into the field on the form.  I'm not sure what you are trying to do and when, so I can't help you much on the event to place the code.  My normal events for items like this are OnCurrent, AfterUpdate, and LostFocus.
0
 
LVL 12

Expert Comment

by:Trygve
ID: 1972303
If you want to save the lookup (could be that the lookup values change by time and you want to keep track of the history) then you should use Belz' approach.

In the AfterUpdate of the controls that you use as part of the criteria for you dlookups insert something like this


me![The field that should get the value] = dlookup... ' Your dlookup expression from the form. Then set the dlookup fields controlsource to the field you want to store the information into.

You could also use the OnCurrent event for the form, but then the fields will be set as you move from one record to the next and this will slow down your application.


If the information that you look up does not change or you want to show the updated info at all times then you should not include the fields in your table, but simply have your dlookups on the form, and link the tables that you do lookups from into any recordsource that you use for reports etc.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now