Results 1 to 4 of 4
  1. #1
    agripa86 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    3

    Exclamation AfterUpdate event code error?

    All,



    hopefully I have posted this in the correct place.

    I should explain I have very limited Access knowledge, but I have been instructed by my work to deal with this issue!

    I currently have a table (tbl_topics) with 2 fields "Topics" and "Sub-Topics" I am attempting to use these to set up some cascading lists on a user form.

    I have a combo box (cbo_topic) which is the first to be accessed by the user. The code i am using to define the RowSource is:

    Code:
    SELECT DISTINCT tbl_topics.Topic FROM tbl_topics ORDER BY tbl_topics.Topic;
    Once the user has selected a topic, the sub topics field (cbo_subtopic) presents the associated sub topics. I have added the following code to the afterupdate field of the cbo_topic (through AfterEvent - Code Builder)

    Code:
    Private Sub cbo_Topic_AfterUpdate()
       cbo_subtopic.RowSource = "Select tbl_topics.SubTopic " & _
                "FROM tbl_topics" & _
                "WHERE tbl_topics.Topic = '" & cbo_Topic.Value & "' " & _
                "ORDER BY tbl_topics.SubTopic;"
    End Sub
    The first combo box is working fine, with the drop down options appearing. However there are currently no options appearing in the second combo box, and no error messages appearing.

    I am more than a little lost at the moment, and attempts to find a solution online have left me with more questions than answers. Can anyone advise where I am going wrong, and how i can resolve this issue

    Thanks

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Why set the rowsource for the subtopic combo with code? Why not just set it in its own rowsource to be dependent upon the first one and then just requery it in the after update event? That's how I do it.

  3. #3
    agripa86 is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    3

    Exclamation

    Quote Originally Posted by boblarson View Post
    Why set the rowsource for the subtopic combo with code? Why not just set it in its own rowsource to be dependent upon the first one and then just requery it in the after update event? That's how I do it.
    As i said - access amateur

    Essentially because searching online seemed to suggest code was the best way to manage this. If there is an easier/better way I am happy to do it that way - could you recommend some instructions or provide some info on how to do it this way?

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    to do it just set it up like my sample here:
    http://downloads.btabdevelopment.com...mbosSample.zip

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

Similar Threads

  1. how to created afterupdate event
    By Brigitt in forum Forms
    Replies: 2
    Last Post: 02-15-2011, 03:23 AM
  2. Replies: 0
    Last Post: 02-01-2011, 04:49 AM
  3. User focus control in AfterUpdate event
    By nosliwmada@gmailcom in forum Programming
    Replies: 3
    Last Post: 12-20-2010, 12:51 PM
  4. AfterUpdate event won't refresh subform!
    By Remster in forum Forms
    Replies: 16
    Last Post: 11-26-2010, 10:06 AM
  5. How to put code in form event.
    By rogdawg in forum Forms
    Replies: 4
    Last Post: 08-06-2010, 03:38 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