Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    300

    Question Unanswered: Record is not Updating

    I am using the following vba code to have a user enter in a customer name in a combo box, and it is supposed to find the selected customer, ie update the information on the form with the selected customer record... I keep getting data mismatch errors

    Private Sub Form_Current()

    Combo222 = Company Name ' Update the Find Record combo box

    End Sub

    Private Sub Combo222_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[Company Name] = " & Str(Me![Combo222])
    Me.Bookmark = rs.Bookmark
    End Sub

    What do I need to do?? - HELP!

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I don't believe the str() is necessary. If I remember correctly, the value property of a combo box will return a string by default. I'm guessing the problem is that you're setting a string to a combo box, as opposed to the value that's in the combo box. You may need to be more explicit. Try setting it to:

    rs.FindFirst "[Company Name] = " & Me!Combo222.Value

    Let me know if this works out for you, I'm rather curious.
    Last edited by Teddy; 12-15-03 at 12:47.

  3. #3
    Join Date
    Nov 2003
    Posts
    300
    I think I understand what you are getting at..
    I deleted the control and started over, actually I let the wizard create it this time and it came up with the following-----


    Private Sub Combo224_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[Cust ID] = " & Str(Me![Combo224])
    Me.Bookmark = rs.Bookmark
    End Sub


    which worked!!! Apparently, I needed to state the Cust ID and not the Customer Name field...

Posting Permissions

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