Results 1 to 10 of 10
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Listbox results from selected submenu record

    Probably a common question



    I have a submenu with a list of records in continuous form.

    I have a listbox of records with the bookings of each school.

    I need to be able to click the submenu record and have it show the bookings for that school in the listbox.

    Because I have made a search box I can't have the listbox show all the records when the main form loads - I need it to show nothing until a record from the submenu is clicked.....

  2. #2
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Note: the main form does not have a record source.

    I have exchanged the listbox for another subform.

    I'm guessing one needs to edit the record source to be of whatever the first subform (subform 1) is selected and that needs to be typed in the query sql however i am not sure how.

  3. #3
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    1. Using listbox - Create a textbox on main form say txtLinkBox. Set its controlsource to the schoolname from subform. It should look like "=[YoursubformControl].[Form]![Schoolfieldcontrol]. Modify the SQL of listbox to include the txtLinkbox as criteria.In the form's current event, you have to requery the listbox.
    2.Using another sub form- Set the SQL for listbox as source for the 2nd subform. Drag this subform to main form. In the 2nd subforms's Property sheet>Data>Link Master fields & Link Child fields, select the txtLinkbox as Master field and the schoolcontrolfield in 2nd subform as child field. Now whenever a record is selected on 1st subform, the corrosponding records will be shown by 2nd sub form.

    After testing, hide this text box.

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by amrut View Post
    1. Using listbox - Create a textbox on main form say txtLinkBox. Set its controlsource to the schoolname from subform. It should look like "=[YoursubformControl].[Form]![Schoolfieldcontrol]. Modify the SQL of listbox to include the txtLinkbox as criteria.In the form's current event, you have to requery the listbox.
    2.Using another sub form- Set the SQL for listbox as source for the 2nd subform. Drag this subform to main form. In the 2nd subforms's Property sheet>Data>Link Master fields & Link Child fields, select the txtLinkbox as Master field and the schoolcontrolfield in 2nd subform as child field. Now whenever a record is selected on 1st subform, the corrosponding records will be shown by 2nd sub form.

    After testing, hide this text box.
    why would you need two subforms? why not just one subform and one listbox and one invisible textbox?

    Also the main form has no record source...

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Click image for larger version. 

Name:	capture.JPG 
Views:	8 
Size:	88.2 KB 
ID:	13460

    Basically you click a school and it opens their booking in the listbox.

  6. #6
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Note: the main form does not have a record source.

    I have exchanged the listbox for another subform.

    I'm guessing one needs to edit the record source to be of whatever the first subform (subform 1) is selected and that needs to be typed in the query sql however i am not sure how.
    I have provided two ways to accomplish the task - one using list box, another using sub-form. Choice is yours.

  7. #7
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by amrut View Post
    I have provided two ways to accomplish the task - one using list box, another using sub-form. Choice is yours.
    oh nice.

    I think I will try first.

  8. #8
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    The hidden textbox changes to each id which is great, the listbox does not refresh with the criteria after the change has been made...

  9. #9
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Try in the subform's current event Me.Parent!Listboxname.requery

  10. #10
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    ah. Works.

    many thanks

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

Similar Threads

  1. How to retain values selected in a listbox
    By Cedarguy in forum Forms
    Replies: 4
    Last Post: 05-09-2012, 10:05 AM
  2. Replies: 3
    Last Post: 02-13-2012, 08:14 AM
  3. Replies: 3
    Last Post: 11-29-2011, 12:54 AM
  4. Selected items in listbox
    By tomodachi in forum Access
    Replies: 1
    Last Post: 09-09-2010, 01:14 PM
  5. Exporting report selected from a listbox to excel
    By GARCHDEA in forum Import/Export Data
    Replies: 1
    Last Post: 08-10-2010, 07:45 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