Results 1 to 7 of 7
  1. #1
    hlogoma is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2011
    Posts
    7

    ComboBox on Form will not Update Based on Selection in another ComboBox

    Hi,



    I have a Form, frmDailyActivity_Alternate, on which I use two Combo boxes one to Filter the other.

    cboClient allows for a selection of a Client and then based on this selection cboCode should only show the Codes that are applicable to the Client selected in the cboClient combo box.

    If the two combo boxes are unbound then these two Combo boxes work as described. Once they are bound, cboClient is bound to ClientId and cboCode is bound to CodeID, they no longer work.
    What happens is the once the client is chosen from the drop down of cboClient, the cboCode selection does not update.

    In the code I do have under cboClient_AfterUpdate()
    me.cboCode.requery
    but to no avail.

    I have also tried me.dirty = false here but this too does not seem to help.

    This problem only happens in the Add a new Record mode.

    I have attached a zipped copy of this test database...it is all fictional, in the hope that you can help me solve this issue.

    Any pointers, suggestions would be most appreciated.

    Thanks,

    Tom.
    Last edited by hlogoma; 07-27-2011 at 01:04 PM. Reason: I forgot to add that the problem is in the Add a new Record mode.

  2. #2
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    Hi your db is under process to sort this error out.

  3. #3
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    Did you compact and repair your database? try to remove all the debugging errors. In VBA mode, goto Debug>>>>Compile your database. I downloaded your db and found it's working. Compacted and repair, added new record. put this line of code on after update event of cboCode:
    Code:
    Private Sub cboClient_afterUpdate()
        Me.cboCode.Requery
    End Sub
    I am attaching back your db:

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    your code is sound, you just have not attached the button the AFTER UPDATE to your code, if you scroll down to your AFTER UPDATE property you will see the line is blank, if you click on the three ... button it will automatically take you to the code you've typed, and you should be good to go.

  5. #5
    hlogoma is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2011
    Posts
    7
    Thanks Khalid and rpeare .... all is well again.
    Just for clarity ... I just went into code and typed in the AfterUpdate event when I created these combo boxes. Is my reading correct that I also needed to use the property sheet and then goto the afterupdate event for the control and click the elipsis?

    Thanks again.

    Tom.

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    That's correct, if you are just typing code after your code is complete you have to attach it to the button even though everything is typed correctly.

  7. #7
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    In access, if you wrote code in VBA for certain control on the form, then if you change or rename your control, the code behind the control become useless. So you have to re-bind your control to your VBA code. This is normal, you can use ellipsis (...) button on the event property sheet of the control to goto the desire code, rebind it and debug. I did the same with your code and its working.

    Good that the problem is sorted out.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 29
    Last Post: 08-16-2011, 05:52 PM
  2. Query based on ComboBox selection
    By pmac in forum Queries
    Replies: 9
    Last Post: 07-27-2011, 07:03 AM
  3. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  4. Replies: 0
    Last Post: 12-16-2009, 01:14 PM
  5. Replies: 0
    Last Post: 04-17-2008, 09:24 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums