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

    Exclamation Unanswered: Trying to Find Record - Combo Box Not Working

    I have a form - Invoice form and when a user clicks the add button, it adds a new record, no problem there but now the user wants to have a combo box that pulls from the customer table, select the customer by ID and Name and that fills in the customer information on the Invoice Form..

    I can't get it to work, the code I have is below and it will only find the First Invoice ID, does not do what I want...

    Code behind Find Customer ID - Combo Box:

    Private Sub FindCust_AfterUpdate()

    Me.RecordsetClone.FindRec "[Cust ID] = " & Str(Me![FindCust])
    Me.Bookmark = Me.RecordsetClone.Bookmark
    'Me!Combo111.Requery

    Mainform_Lock False


    End Sub


    Any suggestions?

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Not really enough information here to give you a definit answer to your problem but perhaps guide you towards the solution.

    First you will need to set up the combobox located within the Invoice form so that is will display the required data (Customer ID and Customer Name). This is relatively easy to do with the query builder.

    Now...In the OnClick event of the ComboBox (which, by the way, is fired when a user selects the customer name) you need to enter code so as to fill in the pertinent areas of your Invoice. Perhaps something like:

    Me.CustomerID = Me.myComboBox.Column(0)
    Me.CustomerName = Me.myComboBox.Column(1)
    Me.CustomerAddress = Me.myComboBox.Column(2)
    etc...

    If your invoice is being generated from stored data (puchases made for example) then you would use the bound information located within the combobox within the query that generates that very invoice.


  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Look at the way you're calling it:

    Quote Originally Posted by databasemon
    Private Sub FindCust_AfterUpdate()

    Me.RecordsetClone.FindRec "[Cust ID] = " & Str(Me![FindCust])
    You are trying to pass a string as criteria to a number field. You either need to drop the Str, or use LIKE.

    Me.RecordsetClone.FindRec "[Cust ID] LIKE '" & Me![FindCust] &"'"
    Me.RecordsetClone.FindRec "[Cust ID] = " & Me![FindCust]
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

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