Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2008
    Posts
    150

    Answered: Populate Data using Combo Box works Periodically. Why?

    Hello,

    I have a combo box on a data entry form called “cboProjNumber” that is populating a table from a query. The values I am populating are listed below. Sometimes, the On Change event works great and sometimes I receive the error below. I have reviewed the query structure, the tab positions and text field names and all looks good. Obviously I am missing something and I know you will catch it.

    On Change Event Procedure:

    <Begin Code>
    Private Sub cboProjNumber_Change()
    Me.PNum_txt.Value = Me.cboProjNumber.Column(1)
    Me.PName_txt.Value = Me.cboProjNumber.Column(2)
    Me.PMgr_txt.Value = Me.cboProjNumber.Column(3)
    Me.PID_txt.Value = Me.cboProjNumber.Column(4)
    Me.CV_txt.Value = Me.cboProjNumber.Column(5)
    End Sub
    <End Code>


    Error Message:

    The expression On Change you entered as the event property setting produced the following error: Object or class does not support the set of events.

    • The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]
    • There may have been an error evaluating the function, event, or macro.

  2. Best Answer
    Posted by Missinglinq

    "The OnChange event of a Combobox fires when a selection is made by dropping the list down and clicking on a selection or (and it's an important 'or') after each character is entered into the Combobox (as one would do expecting the AutoExpand feature to take them to the correct selection.) I expect that it is this latter behavior causing the problem...Access is trying to do the assignment based on the first character typed...not on an actual selection.

    Using the AfterUpdate event of the Combobox (not the Form AfterUpdate!) as Sinndho suggested would alleviate the problem.

    Linq ;0)>"


  3. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You should not use the Change event for this purpose. Use the AfterUpdate event instead.
    see: https://msdn.microsoft.com/en-us/lib...ice.11%29.aspx and https://msdn.microsoft.com/en-us/lib...ice.11%29.aspx
    Have a nice day!

  4. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    The OnChange event of a Combobox fires when a selection is made by dropping the list down and clicking on a selection or (and it's an important 'or') after each character is entered into the Combobox (as one would do expecting the AutoExpand feature to take them to the correct selection.) I expect that it is this latter behavior causing the problem...Access is trying to do the assignment based on the first character typed...not on an actual selection.

    Using the AfterUpdate event of the Combobox (not the Form AfterUpdate!) as Sinndho suggested would alleviate the problem.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #4
    Join Date
    Sep 2008
    Posts
    150
    THANK YOU BOTH for the info and explanations. I pasted the code in the combo box After Update event. So far it is working great! Thanks again for your response and shared knowledge. :-D

  6. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Glad we could help!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #6
    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
  •