Results 1 to 3 of 3
  1. #1
    CT_AccessHelp is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    40

    Clear a combo box if the entry is updated


    I have form with the following code that works great however, I want the user to be forced to select a new Accounting_Code if they change the County in the County combo box. Any suggestions? Right now it requeries the Accounting_Code combo box when the County is changed but there is nothing that forces the user to select a new accounting code therefore, allowing the user to save the entry with an incorrect Accounting_Code.
    The row source for the combo box bound to the field County Code:
    SELECT DISTINCT County FROM tbl_Accnt_code ORDER BY County

    In the after update event of the combo box County, the code is Code:
    Private Sub County_AfterUpdate()
    Me.Accounting_Code.Requery
    End Sub

    And the row source for the "Accounting_Code" combo box is:
    SELECT [AccountingCode] FROM tbl_Accnt_code WHERE [County] = Forms!frm_Expend.County ORDER BY [AccountingCode]
    Attached Thumbnails Attached Thumbnails FRM_Expend.png  

  2. #2
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Not sure about the middle line, but something like this should do you.
    Code:
    Private Sub County_AfterUpdate()
       Me.Accounting_Code.Requery
       Me.Accounting_Code.Value = Null
       Me.Accounting_Code.SetFocus
    End Sub
    The order of the second and third lines might be reversed...

  3. #3
    CT_AccessHelp is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    40
    Solved!!! Thank you!!!

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

Similar Threads

  1. Clear selected value in combo box
    By bbrazeau in forum Programming
    Replies: 6
    Last Post: 08-05-2014, 12:38 AM
  2. Replies: 2
    Last Post: 04-24-2013, 11:52 AM
  3. Replies: 1
    Last Post: 02-03-2012, 03:51 PM
  4. Clear combo box
    By Cindygo in forum Forms
    Replies: 3
    Last Post: 09-19-2011, 09:25 AM
  5. Clear value list in combo box
    By jgelpi16 in forum Programming
    Replies: 4
    Last Post: 05-27-2011, 12:45 PM

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