Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Text Field from ComboBox 1

Status
Not open for further replies.

thehorse

Programmer
Oct 1, 2004
14
US
Search is disabled, so I'm posting this question:

I want to display data in a text field on a form based on a selection in a combo box. I get it to work with a list box, but not with a text box. Here's what I have:

Form name: frm_OfficeReport

ComboBox: cbo_Office; TextBox: txt_officevalue

cbo_Office is populated from a Group By in a query called qry_OfficeCreate

txt_officevalue should use cbo_Office to populate from a query called Office Value (contains two columns: office and a sum expression named Sum$)

In cbo_Office_AfterUpdate, I add:

txt_officevalue = DLookup("[Sum$]", "Office Value", "Office =" & Forms!frm_OfficeReport!cbo_Office)

This doesn't work, but I think it's the syntax of dlookup. Thanks in advance for the help.
 
txt_officevalue = DLookup("[Sum$]", "[Office Value]", "Office='" & Me!cbo_Office & "'")
If Office is defined as numeric get rid of the single quotes.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PH: Thanks, Works well.

Can you briefly explain two things?
1. Why the single quotes and the second ampersand?
2. Me. and Me!
 
single quotes for text fields.
hash for dates.

ampersand is concatenation.

Me. is for referencing properties of the form.
"me.visible=false"
me! is for referencing controls or subforms on form.
"me!txtuser_ID"

think this is right, someone will correct if its not.

B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top