DLookUp not displaying value in form

darth sidious

Registered User.
Local time
Today, 07:16
Joined
Feb 28, 2013
Messages
86
Hi

I've attached the database I'm working on. The problem I have relates to the DLookUp I have on the form frmFindSeats. I have a query for the Combo box 'available seats' which finds all the free seats for you to select one from. The normal price field should display the price for this seat from the 'Seat' table.

I believe I have correctly used the dlookup: =DLookUp("[Price]","Seat","[SeatNumber]=[cboAvailableSeats]")

However, no price is displayed in the Normal price text box. Please help, this has been holding me up for too long!

Kind Regards

Darth
 

Attachments

Try this as your Control Source..
Code:
=DLookUp("[Price]","Seat","[SeatNumber]=[COLOR=Red][B]'[/B][/COLOR]" & [cboAvailableSeats] & "[COLOR=Red][B]'[/B][/COLOR]")
 
Hi

Thanks for your contribution it worked! Can I ask why my version did not work?

Thanks Again

Darth
 
Well when you are using the Criteria of the DLookUp, you simply used the name of the control to get the value from.. However the result of the ComboBox (seat number) is a Text type whihc had values like A01, A02.. When you use the Criteria..
Code:
=DLookUp("[Price]","Seat","[SeatNumber]=[cboAvailableSeats]")
It actually doe snot find any seat number [cboAvailableSeats], what we needed is actually the value from the ComboBox.. so we concatenate, by using Single Quotes which represent that we are looking for a String, then we are passing the value of the combo by using the & &..
So thus leading us to..
Code:
=DLookUp("[Price]","Seat","[SeatNumber]='" & [cboAvailableSeats] & "'")
For more information on usage of DLookUp, look here..
 
Last edited:

Users who are viewing this thread

Back
Top Bottom