I have a form which links to a table in MS Access. My form displays all the data and populates every field. Now I'd like an easier way to navigate through all the fields so I added a combo box.
The problem I'm having is I cannot get the rest of the data to change when I select a different selection on my combo box.
Can someone help?
My current code is below.
Private Sub Form_Load()
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=G:\ITG Budgets\DB TEAM\Contingent Compensation.mdb;"
Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "select COMPANY,DEPT,DEPTNAME,DIV,EMPNAME,EMPNO,FLSA,HIREDATE,JOBCODE,JOBDATE,JOBTITLE,LVL,Maximum,Midpoint,Minimum,PAYGRP,PERF,REPORTSID,REPORTSTO,REVDATE,SALARY,[SALARY PLAN],STATUS,[VP LEVEL 1] from test2 ORDER BY EMPNO", db, adOpenStatic, adLockOptimistic
Dim oText As TextBox
'Bind the text boxes to the data provider
For Each oText In Me.txtFields
Set oText.DataSource = adoPrimaryRS
Next
'Populate the Combobox
Set Combo1.DataSource = adoPrimaryRS
Combo1.AddItem adoPrimaryRS("EMPNO")
Do Until adoPrimaryRS.EOF = True
Combo1.AddItem adoPrimaryRS("EMPNO")
adoPrimaryRS.MoveNext
Loop
End Sub
Private Sub Combo1_Click()
For Each oText In Me.txtFields
Set Combo1.DataSource = adoPrimaryRS
Set oText.DataSource = adoPrimaryRS
Next
End Sub
The problem I'm having is I cannot get the rest of the data to change when I select a different selection on my combo box.
Can someone help?
My current code is below.
Private Sub Form_Load()
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=G:\ITG Budgets\DB TEAM\Contingent Compensation.mdb;"
Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "select COMPANY,DEPT,DEPTNAME,DIV,EMPNAME,EMPNO,FLSA,HIREDATE,JOBCODE,JOBDATE,JOBTITLE,LVL,Maximum,Midpoint,Minimum,PAYGRP,PERF,REPORTSID,REPORTSTO,REVDATE,SALARY,[SALARY PLAN],STATUS,[VP LEVEL 1] from test2 ORDER BY EMPNO", db, adOpenStatic, adLockOptimistic
Dim oText As TextBox
'Bind the text boxes to the data provider
For Each oText In Me.txtFields
Set oText.DataSource = adoPrimaryRS
Next
'Populate the Combobox
Set Combo1.DataSource = adoPrimaryRS
Combo1.AddItem adoPrimaryRS("EMPNO")
Do Until adoPrimaryRS.EOF = True
Combo1.AddItem adoPrimaryRS("EMPNO")
adoPrimaryRS.MoveNext
Loop
End Sub
Private Sub Combo1_Click()
For Each oText In Me.txtFields
Set Combo1.DataSource = adoPrimaryRS
Set oText.DataSource = adoPrimaryRS
Next
End Sub