DLookUp not displaying value in form (1 Viewer)

darth sidious

Registered User.
Local time
Today, 02:43
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

  • Tables 22nd Jan 2013.mdb
    1.6 MB · Views: 72

pr2-eugin

Super Moderator
Local time
Today, 10:43
Joined
Nov 30, 2011
Messages
8,494
Try this as your Control Source..
Code:
=DLookUp("[Price]","Seat","[SeatNumber]=[COLOR=Red][B]'[/B][/COLOR]" & [cboAvailableSeats] & "[COLOR=Red][B]'[/B][/COLOR]")
 

darth sidious

Registered User.
Local time
Today, 02:43
Joined
Feb 28, 2013
Messages
86
Hi

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

Thanks Again

Darth
 

pr2-eugin

Super Moderator
Local time
Today, 10:43
Joined
Nov 30, 2011
Messages
8,494
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

Top Bottom