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!

Combo box value will not display

Status
Not open for further replies.

emmy

MIS
Nov 7, 2000
22
US
My form has a combo box 'Programs' in the header. When a program is selected the form displays all the data for that program. Works great with text boxes.
One text box displays the location of the program. Programs can move to other locations, so I would like to have the locations box be a combo box where I can select a different location and write that to the database.
Programs and Locations are 2 different tables.
When I select a program, the combo box drops down and shows all locations - great (row source is from the locations table). But, I would like it to show the location where the program currently resides.
Here is my code:
Private Sub cmbSelectProgram_AfterUpdate()
Me.Requery
Me!cmbLocName.SetFocus
Me!cmbLocName.Value = Me!LocName
MsgBox Me!cmbLocName.Value
End Sub
I can tell from the msgbox that cbmlocname.value is being set to what I expect it to. However the combo box is not displaying a value. Plus, when drop it down the order is all messed up.
Can anyone point out what I'm missing?
Thank you.
 
try putting a me.requery after you set the value of the combo box...

--------------------
Procrastinate Now!
 
Yeah, I tried that. Still doesn't display. Thanks for the suggestion though.
 
Being curious, I changed the column width property from 0",2" to 2",2" - now I can see my value. I'm still confused because my row source is:
SELECT locations.LocNum, locations.LocName FROM locations ORDER BY [LocName];
Shouldn't the box now show LocNum, LocName (ex 1225,Alpine)?
Have I gone about his all wrong? I'll need the LocNum (key value) later when I update the Program table.
Thanks.
 
Oh, duh.
Me.cmbLocName.Value = Me!LocNum
Column Width = 0",2"
cmbLocName is now equal to the locations number (to reference later) and the box shows the location by name.
Sorry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top