Dlookup help

vicsalt

Registered User.
Local time
Today, 01:05
Joined
Aug 22, 2008
Messages
48
Simple help please

Im trying to get this to work but not very well, I have a table with values in and a second table i wish to create records via a form.
I want to auto fill some of the fields and understand the Dlookup function is probably the best way to go.

I have looked up the examples but struggling to understand how to get it to work

I have created a simple dbase with 2 tables one, part no, customer and die no
a second table called sales and then created a form.
on the form i created a combo box for the die numbers then a second field which should auto fill with the part no. I have used the dlookup comand using the control source

=DLookUp("[Part No]","parts list",[Combo7])

it doesnt work at all. Would someone very kindly create a simple example i could download to play with and help understand.

I seem to be unable to attach my example

Thanks
 
=DLookUp("[Part No]","parts list","[Part No]=Forms!formname.[Combo7]")

or

=DLookUp("[Part No]","parts list","[Part No]=" & Me.[Combo7])

However it isn't the best way. If possible include the values in the recordsource query, if necessy joining the tables to get the other field. Ideally the controls are bound to the recordset.

However sometimes it is necessary to write the required value into a control that is bound to another recordset. This is done with VBA.

Sometimes the source recordset can simply be opened in the VBA and the values written into the controls. This is essentially what happens behind the scenes in a DOmain Function.

However the DLookup goes through the whole process each time it is called so having multiple DLookUps is like running multiple queries. It is much faster to retrieve all the values together.
 

Users who are viewing this thread

Back
Top Bottom