Results 1 to 6 of 6
  1. #1
    Dave D is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jun 2014
    Posts
    45

    Unbound ListBox and Form Open Event w/ SubForm

    I have a main form with an unbound list box. The main form also contains a bound /linked subform. When I click an item in the list box the appropriate records show in the subform. Everything works as needed except when the form is initially opened. The listbox was added using the Wizard, with the "Find a record on my form based on the value I selected in my list box" option.

    No list box item is selected when the form is opened, and the subform defaults to showing some records based on I don't know what.

    When the form opens how do I select the first item in the list box and get the subform to show only those related records? Or, if nothing is selected in the list box (on open) how do I get the subform to show zero records?

    Thank you for any help.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The open event is too early in the process to reference a control on a form. You would need to use the OnLoad event.

  3. #3
    Dave D is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jun 2014
    Posts
    45
    Thank you. That worked for setting the selected item (ListIndex now equals 0 - the first item in the list). However, the subform still does not show the appropriate records when the form is opened even though I have "selected" the first item in the list box.

    What am I missing?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The event sequence is that first the SubForm loads then the MainForm. Try putting something in the Current Event of the form which happens *after* both the SubForm and MainForm are loaded.

  5. #5
    Dave D is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jun 2014
    Posts
    45
    Thank you for your help. My problem was I had the list ordered by date while the form was ordered by ID. Once I set both to the same order by, it worked just fine.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Thanks for posting back with your solution and success.

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

Similar Threads

  1. Listbox Open Form with VBA
    By phineas629 in forum Forms
    Replies: 3
    Last Post: 04-08-2014, 02:28 PM
  2. Replies: 4
    Last Post: 06-24-2013, 07:34 AM
  3. Replies: 2
    Last Post: 04-05-2013, 03:42 PM
  4. On Open form event not working
    By SPE_NY in forum Forms
    Replies: 2
    Last Post: 10-05-2011, 11:53 AM
  5. Replies: 29
    Last Post: 02-13-2011, 01:21 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