Assigning Default Value to ComboBox from a Table Value

Raabi

Registered User.
Local time
Tomorrow, 02:11
Joined
May 19, 2008
Messages
21
Hello everyone

I have a ComboBox with "Row Source Type" as Table/Query. I am trying to assign it a default value from the attached table, programmatically. It does not recognise ListIndex or Slected(index) etc.

Would any wizard help me, with a programatic solution, for getting around this problem.
 
when you say you want to assign it a default value, do you mean when the form loads, the combo box should have the first item selected: if so, do this: on the form that has the combo box, goto the events (open form in design view, double click to view its properties and select the events tab.) select the OnOpen event and add an event procedure. the procedure will be this:

Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo errorhandler
 
Me.Combo2.SetFocus
Me.Combo2.Value = Me.Combo2.ItemData(0)
 
errorhandler:
If Err.Number = 0 Then
Else
MsgBox (Err.Description)
End If
 
End Sub

let me know if that helps
 
Salute to you, Dreamdelerium for so precise and accurate tip.

Thank you very much and have a great time.

Regards,
 

Users who are viewing this thread

Back
Top Bottom