Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2011
    Posts
    2

    Unanswered: select data using two combo boxes

    I was looking everywhere to find the way to be able to select data using two combo boxes:
    first one finds the serial number
    second one finds the MAC address
    I want to be able to select either one of them and populate the rest based on the selection which works ok the second thing that I'm trying to do is to be able to create a new record if neither of them exist.
    The code for both combo boxes:

    Private Sub cmbSerial_Number_Change()
    Me.cmbMACAddress = Me.cmbSerial_Number.Column(1)
    Me.txtModel = Me.cmbSerial_Number.Column(2)
    End Sub

    Private Sub cmbMACAddress_Change()
    Me.cmbSerial_Number = Me.cmbMACAddress.Column(1)
    Me.txtModel = Me.cmbSerial_Number.Column(2)
    End Sub

    I can start creating a new serial number if it does not exist but as soos as I move on to the MAC address and start typing the Serial Number blanks out which I understand why - just don't know the solution.

    Thanks in advance for any help

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    The Change event occurs every time you type a character in the Text zone of a ComboBox. The code that is associated to the event then runs.

    If, as I suppose, both combos have the same RowSource, the code tries to find a match in the second column of one combo (Column(1)) each time you type something in the Text zone of the other combo. When no match exist the text zone of the combo in which the search is performed turns blank (i.e. the Value property of the combo is Null).

    You have to find a way to lock the search mechanism that binds both combos when you want to create a new record. Then, when both new values are typed in (MAC Address and Serial Number), you need to add the values and requery the combos.
    Have a nice day!

  3. #3
    Join Date
    Aug 2011
    Posts
    2
    Thanks for your response. I'll see if I can find the way of getting this to work, otherwise I'll have to create the record before doing the search - wanna run before I can walk LOL

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

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