Results 1 to 13 of 13
  1. #1
    hemantsogani is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    18

    Event After Update not working for Combo box

    I have two combo boxes Country and Region.

    I am using the following code to create the list for the second (Region) combo box:

    Private Sub Country_AfterUpdate()
    Dim strCountry As String
    Dim S As String
    strCountry = Nz(Me.Country.Value, "")
    MsgBox strCountry
    S = "SELECT DISTINCT Region from BirdsWorld WHERE Country = '" & strCountry & "'"
    Me.Region.RowSource = S


    End Sub

    When I import the required objects in a new database, it works fine. I also displays the selected country in the MsgBox. When I create another form with cascaded combo boxes in the database, it stops working and does not even display the MsgBox.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    hemantsogani is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    18
    I have attached Database2
    Attached Files Attached Files

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    What does "doesn't work" mean? Works for me with the sample db you posted - except that there is no code for a message box.
    Did you make sure to select a state for which you have data?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    And that only state is New York!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    hemantsogani is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    18
    I am attaching two screenshots.
    1. BirdsUSADataEntry with state of New York selected but blank Region
    2. Code from BirdsWorldDataEntry which has the MsgBox. This MsgBox does not show up when I try to select the Region after selecting a country.

    In my first post I had said that it works initially and then stops working. It is not working for me in the database that I had attached.
    Attached Thumbnails Attached Thumbnails NewYork.jpg   CodeForCountry.jpg  

  7. #7
    hemantsogani is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    18
    I tried again. Created a new Database and imported the same objects from my original database. The forms worked as expected. I added a new form Insect which also worked.

    I closed the database and opened in again. The forms stopped working!!

    I am attaching a file with the screenshots and the new database
    Attached Files Attached Files

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    This MsgBox does not show up when I try to select the Region
    Then there is something different between what you're looking at and what you posted. Here is a pic with New York and a region value of Home on the US form.
    Click image for larger version. 

Name:	aHome.jpg 
Views:	19 
Size:	21.3 KB 
ID:	42610

    There is no code at all on the region combo...

    FYI - you should turn on the option for Require Variable Declaration so that your (new) modules have Option Explicit at the top as well as Option Compare (whatever) and add the line to existing modules - otherwise you deserve all the anguish you inflict on yourself!

    Not related to your issue, but I'd say that having a table of data related to countries, then one for US alone is a bit strange. US is a country?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    hemantsogani is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    18
    I realized that the problem is not related to the combo box alone. The VBA code is not activated for any event like clicking the Undo and Save buttons.

    Close button works as it starts a Macro and not VBA code.

    I had got a message once while closing another database stating that I should backup the database and then save the database after stripping the VBA code. I thought it would be difficult to get the code working again and saved it without stripping the code. Could it have created a problem for every database I use?

    Is there a way out?

  10. #10
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by hemantsogani View Post

    ...it works initially and then stops working. It is not working for me in the database that I had attached.
    This is, I think, the telling fact...why it works for us and not for you!

    In version 2007 and later, when no VBA code executes, the problem is usually that the folder holding the database hasn’t been designated as a "Trusted" location.

    To "Trust" your folder, click (at least in v2007):

    • Office Button (top left)
    • Access Options (bottom of dialog)
    • Trust Center (left)
    • Trust Center Settings (button)
    • Trusted Locations (left)
    • Add new location (button)

    Access will run code, when going from Design View to running it, in Form View, even with the Folder not 'trusted,' but will balk when opened directly in Form View, under the same conditions.

    Apparently the Access Gnomes assume if you are running it from Design View, you are the developer, and can be ‘trusted,’ but not if running it directly by opening the Form from the navigation panel!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    hemantsogani is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    18
    I had changed the options on Trust Center in an attempt to stop a security warning popup window each time I opened a hyperlink. I stopped getting the message bar


    which I used to get whenever I opened a new database file.

    VBA code remained disabled in the database and so the code for the "events" did not execute.
    I started getting the message bar after I reverted to the original options in the Trust Center.

    VBA code was enabled once I clicked the Enable Content button and the forms started behaving as expected.

  12. #12
    hemantsogani is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    18
    I had changed the options on Trust Center in an attempt to stop a security warning popup window each time I opened a hyperlink. I stopped getting the message bar<br><br><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAnoAAAAnCAYAAAC YJeUMAAAPbElEQVR4Ae2d64+dVRnF54/jD8AYlYpBUSFEkZoQRIhSLQiUCAJWquAHvMVYlGCCflEj37RBE S8J1QABDcjFXugUGlvIa34nrMnice/3vGfOmRl6skh29uW5rf3stXefvsPAxuaZN4a05CAcCAfCgXAgH AgHwoH148BGDnX9DjVnmjMNB8KBcCAcCAfCATiQQi9fNPNFNxw IB8KBcCAcCAfWlAMbf3n6qSEtOQgHwoFwIBwIB8KBcGD9OLDxz PFDQ1pyEA6EA+FAOBAOhAPhwPpxYOPtc78c0pKDcCAcCAfCgXA gHAgH1o8DKfRS6KbQDwfCgXAgHAgHwoE15UAKvTU92PytbP3+V pYzzZmGA+HAK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DlQOpNBLoTepIDv77 PgvZqj4o0e3Ei3zPD7hQDgQDoQD4cDucyCFXgq9yUXZ5j8ON7/seZGHTi7y7l/k5Dw5DwfCgXAgHGhxIIVeCr2FCrOzLzzU/k3cYwcGZC2SZS2PTzgQDoQD4UA4sDccoNBLW48cTLlDG1OU5un wf7o4c/y+4dQfbp01xudP/jRF3oT/nMi83Ea+Nw9h8p68hwPhQDgQDqwDB1ZS6K1DIrKHXOhwIBwIB8 KBcCAcWDcOpNDLV7d8eQ0HwoFwIBwIB8KBNeXAxjPHDw1pyUE4 EA6EA+FAOBAOhAPrx4GN1157bUhLDsKB5Thw8M67h9qS0+Vymv wlf+FAOBAOLM+BjZMnTw5pyUE4sBwHXnjxX4O3r911b+5V3pZw IBwIB8KBPefAxubm5pCWHIQDy3HgpZdfGbzdcfc3c6/ytoQD4UA4EA7sOQc2zp07N6QlB+HAchx45dXXB293feNbuVd5W 8KBcCAcCAf2nAMbFy5cGNKSg3BgOQ7858SpwdvX7/927lXelnAgHAgHwoE958DGkH+SgWRg6QycfmNz8HbP4QeX9hkH yUAykAwkA8nAshn4HzH+enlt/4/+AAAAAElFTkSuQmCC" alt=""><br>which I used to get whenever I opened a new database file.<br><br>VBA code remained disabled in the database and so the code for the "events" did not execute.<br>I started getting the message bar after I reverted to the original options in the Trust Center.<br><br>VBA code was enabled once I clicked the Enable Content button and the forms started behaving as expected.<br><br>

  13. #13
    hemantsogani is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    18
    Copying the image introduced unreadable text. Posting it again.

    I had changed the options on Trust Center in an attempt to stop a security warning popup window each time I opened a hyperlink. I stopped getting the message bar (image attached).

    I used to it get whenever I opened a new database file. VBA code remained disabled in the database and so the code for the "events" did not execute. I started getting the message bar after I reverted to the original options in the Trust Center. VBA code was enabled once I clicked the Enable Content button and the forms started behaving as expected.
    Attached Thumbnails Attached Thumbnails MessageBar.jpg  

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

Similar Threads

  1. Replies: 1
    Last Post: 09-27-2019, 10:58 AM
  2. Event Code Not Working
    By angie in forum Access
    Replies: 2
    Last Post: 04-03-2018, 11:53 AM
  3. Replies: 7
    Last Post: 03-30-2015, 10:04 AM
  4. Replies: 6
    Last Post: 11-05-2014, 05:27 PM
  5. Replies: 7
    Last Post: 05-08-2014, 10:34 AM

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