Updating a text box

smith.stuart

New member
Local time
Today, 19:39
Joined
Dec 14, 2000
Messages
8
Ok I'm ripping my hair out here. Very simply I want to update a text box's text after selecting a value from a combo box. The items in the combo box are taken from a field in say Table1 and the text box must display a field from the same record in the same table. However, I can't get the text box to update. Am I missing something very simple???
 
If the combox box holds the value you want in the textbox, then on the afterupdate of the combobox put the following:

me.textboxname.value = me.comboxname.value

Hope this helps
Andy
 
Thanks for the reply but not quite what I wanted. The text box is not for displaying what is in the combo box but a field that is in the same record. For example, if a table had first names and surnames as two seperate fields in a table and I chose a first name in the combo box I want the surname to appear in the text box. Any more replies would be much appreciated.
 
In the AfterUpdate of your Combo box

Me.(yourtextboxname) = Me.Combo0.Column(2) With "Combo0" being the name of your combo box and (2) being whatever column number equals the text box you want to fill with (0) being the first column in the table.

i.e. Me.Employees = Me.ComboBox.Column(1)
Me.SSN = Me.ComboBox.Column(2)

Do this for each text box you want to auto fill from the combo.

I'm sure there are other ways to do this but I am fairly new at this and this is the easiest for me.

Hope this helps,

Toni
 
To do this you need to use dlookup.
To set this up, on the after update event of the combo but the following code:

Me.textboxname = DLookup("[serial no]", "[productstable ]", "[product]=" & """" & [Forms]![formname]![Product] & """").

this is based on a product and serial no example.

Explanation..

Dlookup = [field to lookup],[from where],[combo value]=[forms][formname][combo value]

ps. This is only valid if you are looking up data from a table, if the recordsource is a query , then you need to carry out Toni's suggestion.
This should do what you want.
Andy
 
stuart

i am not sure if i got u right but i would do it in VBA:
in the Onchange event go to the code builder and
private sub combo1_click()
' if not set the recordset then set rs=....
text1.text=""
if combo1.seletext="A" then
text1.text=rs![fieldname]
else
if combo1.seletext="B" then
......
......
.....
'you can actually use select case statement ...
end if
end sub

i hope this helps ... if not please lemme know ...
Thanks
walker
 
Thank you thart21, that worked. Column count property set to 1 to only show in the combo box what I wanted the end user to see, even though the combo box contained three columns. Cheers.
 

Users who are viewing this thread

Back
Top Bottom