I am designing my first database using visual basic, althought i have good previous Access Experience however this rarely involved using visual basic.
I have just pulled some data from my tbl_job. which links client_id, supervisor_id in order to create a job. (Code shown below):
Option Compare Database
Option Explicit
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Form_Load()
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
rs.Open "tbl_jobs", cn, adOpenDynamic, adLockOptimistic, adCmdTable
FillControls
End Sub
Private Sub FillControls()
txtJobID.SetFocus
txtJobID.Text = rs.Fields.Item("Job_ID")
txtClientID.SetFocus
txtClientID.Text = rs.Fields.Item("Client_ID")
txtSupervisorID.SetFocus
txtSupervisorID.Text = rs.Fields.Item("Supervisor_ID")
End Sub
This works fine in displaying the data, but now I want to create a dropdown menu, so that when i select a client_name it updates the txtClientId.
I have placed a combo box on the form and managed to make it display the list of data using a SQL Statement, however the trouble i'm having i cant workout/find the code to enter so that when i change the client name in the dropdown menu it updates the client_id.
Obviously im missing some code and therefore any help on this problem would be much appreciated.
I have just pulled some data from my tbl_job. which links client_id, supervisor_id in order to create a job. (Code shown below):
Option Compare Database
Option Explicit
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Form_Load()
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
rs.Open "tbl_jobs", cn, adOpenDynamic, adLockOptimistic, adCmdTable
FillControls
End Sub
Private Sub FillControls()
txtJobID.SetFocus
txtJobID.Text = rs.Fields.Item("Job_ID")
txtClientID.SetFocus
txtClientID.Text = rs.Fields.Item("Client_ID")
txtSupervisorID.SetFocus
txtSupervisorID.Text = rs.Fields.Item("Supervisor_ID")
End Sub
This works fine in displaying the data, but now I want to create a dropdown menu, so that when i select a client_name it updates the txtClientId.
I have placed a combo box on the form and managed to make it display the list of data using a SQL Statement, however the trouble i'm having i cant workout/find the code to enter so that when i change the client name in the dropdown menu it updates the client_id.
Obviously im missing some code and therefore any help on this problem would be much appreciated.