Dlookup help

vand_uk

Registered User.
Local time
Today, 17:20
Joined
Aug 26, 2004
Messages
32
Im just testing out this feature,

im trying to enter a product id and get the product name entered in automatically into a form. I have the product name on the forms' controlsource set to =DLookUp("[ProductName]","Products","[productid]=Forms![Order Details]!ProductID")

this works but only when i close the form and open it again. Is there any way it will happen in real time?

Thanks
 
when you enter your product id, try to requery your form on the afterupdate event.
 
=DLookUp("[ProductName]","Products","[productid]= " & Forms![Order Details]!ProductID & "")

or

=DLookUp("[ProductName]","Products","[productid]= '"& Forms![Order Details]!ProductID & "'")


???
ken
 
i know where the after update event is but how do i requery?
 
in the afterupdate event click on those 3 dots ... and choose Code Builder then type Me.Requery
 
Thanks ken, but those are both giving #Error in the product name field.
The re.query doesnt seem to be doing it either!

When i started this I thought it'd be simple!! Haha.

Thanks for your help so far
 
Is productID an integer (autonumber)?

kh
 
My bad:

=DLookUp("[ProductName]","Products","[productid]= " & Forms![Order Details]!ProductID)

???
ken
 
ive been playing around with the requery and i've managed to do it.

Thank you so much I never would have come up with that!
Cheers
Tom
 
I would never use DLookup() for this. It is the worst possible solution. A query that joins to the lookup table as the form's RecordSource is the preferred solution. But take a look at this example db for a comparison of the three most commonly used techniques:
Fill form fields
 

Users who are viewing this thread

Back
Top Bottom