Solved

control source and dlookup ?

Posted on 1998-12-30
3
466 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

856 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