Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

control source and dlookup ?

Posted on 1998-12-30
3
Medium Priority
?
488 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 150 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

704 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