PDA

View Full Version : Combo Box help



deustim
12-15-2011, 11:04 AM
I want to populate text boxes on a form based on the selection from a combo box.

Sub PopulateControlsOnForm5()
'populate the controls on the form with the values of the
'current record in the local disconnected recordset
'use the same field names as the table from
'which it was generated.
If Not rsContacts4.BOF And Not rsContacts4.EOF Then

txtSAUSAName.RowSource = ""
txtSAUSAName.LimitToList = True
txtSAUSAName.ColumnCount = 1
txtSAUSAName.RowSourceType = "Value List"
txtSAUSAName.BoundColumn = 1

Do While Not rsContacts4.EOF
'this is my combo box
txtSAUSAName.AddItem rsContacts4!txtSAUSAName

'These are the text boxes i wish to populate with the values from the tblSAUSA table.
Me.txtSAUSAAddress = rsContacts4!txtSAUSAAddress
Me.txtSAUSACity = rsContacts4!txtSAUSACity
Me.txtSAUSAState = rsContacts4!txtSAUSAState
Me.txtSAUSAZipCode = rsContacts4!txtSAUSAZipCode
Me.txtSAUSAPhone = rsContacts4!txtSAUSAPhone
Me.txtSAUSAFax = rsContacts4!txtSAUSAFax
Me.txtSAUSAEmail = rsContacts4!txtSAUSAEmail
rsContacts4.MoveNext
Loop
ElseIf rsContacts4.BOF Then
'past beginning of recordset so move to next record
rsContacts4.MoveNext
ElseIf rsContacts4.EOF Then
'past the end of recordset so move back to previous record
rsContacts4.MovePrevious
End If
End Sub

any help would be greatly appreciated.