Combo Box Problem

EssexRob

Registered User.
Local time
Today, 20:00
Joined
Jan 30, 2006
Messages
22
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.
 
Why don't you just bind the combox to Client_ID?

Otherwise, on the after update event of the combox, you would use:

me.txtClientID = me.cboClientID
 
cheers the code worked.

thanks alot
 

Users who are viewing this thread

Back
Top Bottom