Results 1 to 5 of 5
  1. #1
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55

    Open a record in a new form from a list box with criteria of a subform

    I have a search List box that lists all orders (customer details and their orders) the tables are related one to many (one customer has many orders). The issue is that the form that is being opened from the list box is CUSTOMER with a subform of ORDER. My list box was originally linked to the form that is opening through ClientID. But of course this causes an issue if the client has more than one order. I tried my best to make the listbox linked to the OrderID in the ORDER subform but it does not recognise it and then just brings up a blank form. Is it possible for a list box to reference a subform or am fighting a losing battle?
    Here is the 'where' criteria I used in my macro to try and reference the subform: [Forms]![Frm_OrderClient1]![Frm_OrderSub1]![OrderiD]=[Forms]![Frm_FindBooking]![SearchList]



    But I just get a blank form. Any help appreciated.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by shaunacol View Post
    ... The issue is that the form that is being opened from the list box is CUSTOMER with a subform of ORDER....
    Your where criteria should be filtering the Main Form not the Sub Form. The sub form should be dependent on the main form via the Main/Child link fields.

    Where
    [Forms]![Frm_OrderClient1]![OrderiD]=903

  3. #3
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55
    Yes unfortunately I cant do that as customer is the main form and they have many orders so access doesn't know which customer order to display and therefore displays nothing (I want that particular order and not all of them). Ive figured it out now and I just use the Order form as my main form and put the customer as a subform. Since the record is already created and im just going back to it for any edits this doesn't seem to be an issue and now my list box knows which ORDER to open for that customer. Thanks for your help.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I have forms with multiple Sub Forms that do not have any Master/Child Link properties. You do not have to have Master/Child properties defined. What I do is use VBA to dynamically assign the Recordsource of the SubForm. In your situitation, I might have VBA consider the ListBox in the other form and store the ListBox value(s) in variables. Then, I could use the variables in the SQL for the subform. I would probably go through the extra step of using variables to avoid dependencies on the form with the ListBox.

  5. #5
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55
    Thanks for your suggestion, I don't think my coding is good enough to achieve this but it looks like a more robust way. Its all working perfectly now so its ok for me

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

Similar Threads

  1. Replies: 10
    Last Post: 12-17-2014, 03:31 PM
  2. Replies: 13
    Last Post: 07-24-2014, 04:30 PM
  3. Replies: 3
    Last Post: 08-26-2012, 10:04 PM
  4. Replies: 1
    Last Post: 11-30-2010, 10:05 AM
  5. Open form based on Subform criteria
    By Suzan in forum Programming
    Replies: 0
    Last Post: 04-25-2006, 02:28 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