Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a record with a selection from unbound combo box

Status
Not open for further replies.

jamesem

Technical User
Sep 17, 2002
1
US
I have syncronized two combo boxes, running the following event procedure "after update" in the first combo box:

Code:
    Private Sub cboDepartment_AfterUpdate()
        Me.cboJobCode.Requery
    End Sub

    Private Sub Form_Open(Cancel As Integer)
        With Me
            .cboDepartment = ""
            .cboJobCode = ""
        End With
    End Sub

What I am doing is basing the job codes displayed in the second combo box on
the department selection made in the first. Unfortunately, this won't run
with a control source selected. How can I make use of the data displayed in
the second box if it is unbound? I need this data to be written to a record
in a table. Any suggestions?

TIA


 
Try this on for size:

Dim dbs as database

set dbs = currentdb


MyJobCode = me.cboJobCode

dbs.execute "UPDATE tblYourTable SET tblYourTable.JobCode = " & MyJobCode & " WHERE (((tblYourTable.Name)="whatever"));

 
[bugeyed] It appears the JobCode is a string so don't forget to add single quotes around 'MyJobCode' in your query.

VBSlammer
redinvader3walking.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top