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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set a textbox value based on Combobox value 1

Status
Not open for further replies.

Jade3942

Technical User
Apr 25, 2008
17
GB
What I have is a combobox that has as it's bound value the field [TEMP ID], amongst other things looked up by the box for display purposes in the drop-down list are [Full Name] and [Post Code].

I need to send that post-code value to a textbox after the combobox updates.

However as the combobox only stores the [Temp ID] I can't just use SetValue to push the [Post Code] to the textbox involved...and I cannot change the bound value of the combobox as the [Temp ID] is pivotal to the form in use.

Is there simple vba code to attach to the AFTERUPDATE property of the combobox to lookup and send the relevant [post code] to the textbox?

Any help appreciated.
 
On AfterUpdate of the combobox,

me.textboxname = me.comboboxname.column(#)

where # is the column number of the PostCode as it appears in the rowsource of the combobox. Just remember that the column numbering starts with zero rather than 1 and to count 0" width columns as well.

Let them hate - so long as they fear... Lucius Accius
 
This code seems to be along the right lines I think... used in the Control Source of the textbox, but I cannot get it to return the right result.. I think my syntax is at issue here..

[Call Form3] is a parent form, [ring around3] is the subform, the [temp id] is a field on the subform which is set to continuous form mode.


=DLookUp("[post code]","temps",[TEMP ID]=[Forms]![call form3]![ring around3]![temp id])
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top