Solved

control source and dlookup ?

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why can't I update my query in datasheet view (or my form). 6 20
Access Update Query 1 20
Dlookup MSACCESS 5 24
Trying to force an answer in a combobox 7 11
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server views 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 Access…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 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