Link to home
Start Free TrialLog in
Avatar of srikanthess
srikanthess

asked on

Unbound text box to display data from query

Hi all,
I have a form "xx" based on table "Tblxx", with a combobox "CmbaaID" and I have a query "yy" based on table "tblyy". "Tblxx" and "Tblyy" are related with "aaID". The query "yy" is filtered to "aaID" with
[Forms]![xx]![CmbaaID], which works fine.
The Query has fields aaID, bb, cc and dd from "Tblyy"
The form "xx" has a unbound textbox where I want to display the data "dd" from the filtered query. I just gave it a shot by writing a code in text box like
 =[Query]![yy]![dd]
but this is returning "Name?" error in the text box.
I am quite new for Access and as well VBA.
Can some body guide me through please?
Thanks in advance.
sri
Avatar of frankytee
frankytee
Flag of Australia image

a textbox can only show 1 column from 1 record, you are trying set it to multiple records from a query. also you need to either use a recordset (more work) or a function like dlookup
you need to pass a whatever criteria to filter it accordingly.
for eg below returns dd from table/query "yy" where aaID = 5
=dlookup("dd", "yy", "aaID = 5")
Avatar of srikanthess
srikanthess

ASKER

Hi Frankytee,
Thanks for your reply,
Can I code the Text box like
=dlookup("dd","yy","aaID=CmbaaID"), ' Where CmbaaID is the combo box in the form "xx" of the Text Box .
If the data type in the field "dd" is Date and Time, How I should code it with dlookup?
Thanks again,
sri.
ASKER CERTIFIED SOLUTION
Avatar of frankytee
frankytee
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It is working perfect,
Thanks a lot
thanks you're welcome