By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,730 Members | 1,480 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,730 IT Pros & Developers. It's quick & easy.

DLookup value from a combo box display results in text box

P: 3
Hi,
I have a table called OccupancyT with following two fields - Occupation (text field) & Hazardclass (number field).
In my form, Occupation is shown as a combo box (called ComboOcc). I would like to display the Hazard Class code based on the selection of my combo box.
I tried this but no results was displayed:
=DLookUp("[Hazardclass]","[OccupancyT]","[Occupation]= '" & [Forms]![PropertyWorksheet]![ComboOcc] & "'")
Hope you could assist. Thanks.
2 Weeks Ago #1
Share this Question
Share on Google+
7 Replies


NeoPa
Expert Mod 15k+
P: 31,606
Hi Puvana.

I would suggest that you use multiple columns in your ComboBox then, in the AfterUpdate Event procedure, set the value of an unbound TextBox Control from the relevant column of the selected row. The property (of the ComboBox) to use is .Column(Index, [Row]). [Row] is unused if you want to refer to the selected one.
2 Weeks Ago #2

P: 3
Hi NeoPa,

Thanks for the guide. But i would like to display the respective Hazard Class when a particular Occupancy is selected.
Index only gives me the row number.
My Dlookup does not give me error, but its empty.

Please advise. Thanks.
2 Weeks Ago #3

P: 65
Include (join) table OccupancyT and field Hazardclass in the query that you use as rowsource for the combobox.

Then use an expression for the textbox like:

Expand|Select|Wrap|Line Numbers
  1. =[ComboOcc].[Column](1)
2 Weeks Ago #4

NeoPa
Expert Mod 15k+
P: 31,606
Puvana:
Index only gives me the row number.
I'm sorry but that is just not correct. Index gives you nothing. YOU give the Index to the property and that tells it which column to return the value from.

This was explained fully and clearly in my earlier post. I suggest you try again to follow those instructions. If followed correctly they will do exactly what you requested.
2 Weeks Ago #5

P: 3
Hi NeoPa & castusdata,

Thank you both for your assistance. I managed to resolve my Dlookup. It finally worked after several tries.

Appreciate your assistance.
2 Weeks Ago #6

P: 65
Great! Then please mark as answered.
2 Weeks Ago #7

NeoPa
Expert Mod 15k+
P: 31,606
They did, but I reset it.

From their comment I could only deduce their issue was resolved. Not which post most contributed to that resolution.

The Best Answer is there to allow searchers to skip straight to the post of most significance in a thread and save them having to go through the whole discussion.
2 Weeks Ago #8

Post your reply

Sign in to post your reply or Sign up for a free account.