Combo Box Default Value

  • Thread starter Thread starter Icy
  • Start date Start date
I

Icy

Hello. I use a Unbound Combo box as a look up with the row source
"SELECT Visitor.VisitorID, [LastName] & ", " & [FirstName] & " " &
[MiddleInitial] AS Expr1 FROM Visitor ORDER BY [LastName] & ", " &
[FirstName] & " " & [MiddleInitial];" The record fields display information
when different visitor is picked. However, when I open the form, the lookup
combo always blank and record field always has information in it. I want to
set Combo box to a default value and have the record field display correspond
information. I have try to code the
Sub Form_Load ()
Combo0.SetFocus
Me.Combo0.defaultvalue = Combo0.Column (0,0)
Me.requery
However, only the Combo0 display the correct vistor name and the record
field still display other visitor information even after Requery.
Same happen when I set Combo0.Value = Text25.Value. Only Visitor name
appears on the combo box, the record field still don't change. Please help.
Thanks!
 
To set the value of a combo box, you need to remember that you need to set
the BOUND column value, not necessarily the visible column value.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.
 
Let's say you have a combo box which has two fields, the first one is bound
and is EmployeeID and the second field is EmployeeName. The first field's
width is set to 0" so it doesn't show and the name is set to 2" so it shows.

So, if I want to set the value of the combo box to my employee, say Bill
Gates, I would need to know his employee ID number of 1 and set the value

Me.MyComboBoxName = 1

and then it would display Bill Gates in the text.
Thank you for your reply, could you give me sample how to set the bound
column value??

--
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
Access 2000, 2002, 2003, 2007

Message posted via AccessMonster.com
 
Thank you for your support. I know how to set the value to the unbound combo
box. however, the name in the combo box changed, but the field related to it
did not change.
Me.MyComboBoxName = 1
Me.Requery
Combo box shows "Bill Gate"
but the record field still show
Last Name: Joe ------- instead of Gate
First Name: John ------- instead of Bill
I have to click on combo box and chose "Bill Gate" in order for the record
filed to change. is there anyway or code to make this happend once you assign
a value to Me.MyComBoxName For example.
Me.MyComboxName = Forms![MainForm]![Log SubForm]![TeacherID].Value
Thank you again for your assistance.
 
Back
Top