Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2009
    Location
    Berkshire, UK
    Posts
    30

    Question Unanswered: Store combo box value in another table?

    I'm sure there's an easy answer to this but my feeble brain can't see it.

    I have a table tblStatus with two fields, StatusID (autonumber) and Status (text). I have a combo box cboStatus that displays the list of Status values.

    I want to select a Status value from the combo box and write the corresponding StatusID to a record (StatusID) in a different table (tblHolders), if necessary overwriting what's already there.

    Any advice gratefully received!

  2. #2
    Join Date
    Aug 2009
    Location
    Up Nort' Wi
    Posts
    140
    Are you using bound or unbound forms?

    Basically you just edit the appropriate record with the value of the combobox (I'm anal, I almost always use a CInt(cbo_ComboName.Column(0)) when saving that value to a table).

    If you need help with setting up the recordset I'll be glad to help. If you're using bound forms it should edit and update when you "save" the record.

    Good luck,

    Sam
    Last edited by SCrandall; 03-05-10 at 09:29. Reason: It's early and I can't spell
    Good, fast, cheap...Pick 2.

  3. #3
    Join Date
    Nov 2009
    Location
    Berkshire, UK
    Posts
    30
    Thanks for your reply.

    The form is bound to tblHolders, which is where I want the value of StatusID written. cboStatus gets its value list from tblStatus. I've attached a relationship diagram of the database which may make things clearer.

    cboStatus displays the dropdown list of Status values OK, but doesn't allow me to select one (nothing happens).

    I'm probably doing this all wrong, but it's my first attempt at a database.
    Attached Thumbnails Attached Thumbnails relate.jpg  

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You could try this:
    Code:
    Private Sub cboStatus_AfterUpdate()
        
        Dim strSQL as String
    
        strSQL = "UPDATE tblHolders SET StatusID = " & Me.cboStatus.Column(0).Value  & _
                 " WHERE <Identify the row to modify in tblHolders here>"
        Currentdb.Execute strSQL
    
    End Sub
    Have a nice day!

  5. #5
    Join Date
    Nov 2009
    Location
    Berkshire, UK
    Posts
    30
    Thank you, I will try that.

    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •