Hi, I have a userform with a combobox and some texboxes I can get data from access database for the combobox but I also want it to populate the textboxes with a combobox change event how do I do that ?
VBA Code:
Private Sub Userform_Initialize()
On Error GoTo UserForm_Initialize_Err
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=myDatabase.mdb"
rst.Open "SELECT DISTINCT [Product Code] FROM Stores Code ORDER BY [Product Code];", _
cnn, adOpenStatic
rst.MoveFirst
With Me.ComboBox1
.Clear
Do
.AddItem rst![Product Code]
rst.MoveNext
Loop Until rst.EOF
End With
UserForm_Initialize_Exit:
On Error Resume Next
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
Exit Sub
UserForm_Initialize_Err:
MsgBox Err.Number & vbCrLf & Err.Description, vbCritical, "Error!"
Resume UserForm_Initialize_Exit
End Sub
Private Sub ComboBox1_Change()
??????
End Sub