Results 1 to 15 of 15
  1. #1
    tim_tims33 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    62

    Problem with Filtering a Look Up (in subform) using parameters on main form.

    Hi,

    I am creating a booking database for a Bus Hire company. There is also an Invoice element to it, which will Invoice customers for a range of bookings that they've made.



    You will see in the screen image, the relationships between the four tables:
    -tblInvoice
    -tblInvoiceDetails
    -tblCustomer
    -tblBooking

    IN tblBooking (see screen dump) the customer is allocated a booking number and so on.

    However, at the end of the month, the Customer will be invoiced for specific bookings. I would like to, firstly, select the customer in the Invoice form, then in the InvoiceDetails subform, select THE BOOKINGS THEY HAVE PREIVOUSLY Made using a look up. (see screen dump called frmInvoice.Gif) Obviously, i don't want every single booking to appear!

    I have applied a criteria to the data source for the look up. (see image datasource...GIF) with
    forms![frmInvoice]![CustomerID] in the hope that the query will search for BookingIDs where the currently selected CustomerID (in Form Invoice) finds a corresponding match in tblBooking.

    This isn't working!! Why not??

    If anyone has any ideas, that'd be much appreciated.

    Thanks

    tim
    Attached Thumbnails Attached Thumbnails tblBooking.GIF   frmInvoice.GIF   data source for BookingID look up.GIF  

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    This is a form/subform? Master/Child links properties are set? The query you show is for the BookingID combobox? Do you want to provide project for analysis?
    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
    tim_tims33 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    62

    Problem with filtering a look up in subform, using parameters from main Invoice Form

    Quote Originally Posted by June7 View Post
    This is a form/subform? Master/Child links properties are set? The query you show is for the BookingID combobox? Do you want to provide project for analysis?
    I have attached the DB.

    Yes, it is a Form with subform InvoiceDetails.

    If you can shed any light on the matter,it'd be appreciated

    thanks
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I added some test data. The BookingID combobox shows only the bookings associated with that customer. What you need is code that will requery the combobox after selection of customerID for a new invoice record. Use the AfterUpdate event of CustomerID combobox. I use only VBA but macro can probably do it.

    I always give subform container control a name different from the object it holds, like ctrDetails and name controls different from the field they are bound to, like cbxBookingID. So in VBA:
    Forms!frmInvoice.ctrDetails.Form.cbxBookingID.Requ ery
    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.

  5. #5
    tim_tims33 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    62
    Hi, thanks for you reply...but this doesn't deal with the problem.

    You said that the BookingID combo box shows only the bookngs associated with that customer. That's what I am trying to achieve. If this has worked for you...then that seems fairly strange.

    For example, having already selected customerID 2, let's say, in the main form...
    ...in the corresponding subform, i would like to click on combo BookingID and see the bookings appear JUST FOR THAT CUSTOMER.

    Currently, I am seeing all bookings every made.

    From what i understand in your solution... you are suggesting I requery the subform's data everytime i change the customerID. But, I only select the CustomerID once at the top and select their related bookings in the subform correspondingly.

    Hope this makes sense.

    thanks

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I should have said that the BookingID combobox shows only the bookings for the customer when the form first opens. I am suggesting that after selecting a customer the combobox RowSource needs to be requeried, not the subform.
    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.

  7. #7
    tim_tims33 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    62
    Quote Originally Posted by June7 View Post
    I should have said that the BookingID combobox shows only the bookings for the customer when the form first opens. I am suggesting that after selecting a customer the combobox RowSource needs to be requeried, not the subform.
    Hi, thanks again for your reply...but having difficulty implementing the 'requery'.

    On the 'After Update' event for the CustomerID control on frmInvoice...i tried running a macro which states:
    - Requery
    - Control: forms!fsubInvoicedetails!cboBookingID

    However, whenever i change the CustomerID on the main form... i get the following error message:
    ''There is no field named forms!fsubInvoicedetails!cboBookingID in the current record''.

    I've probably done it wrong! Any ideas?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I don't use macros, only VBA.

    Did you give the subform container a name different from the object it holds?

    Refer to my ealier post (#4) for the suggested syntax.
    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.

  9. #9
    tim_tims33 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    62
    Quote Originally Posted by June7 View Post
    I don't use macros, only VBA.

    Did you give the subform container a name different from the object it holds?

    Refer to my ealier post (#4) for the suggested syntax.
    By container, do you mean the subform in which the control is found?

    In that case, it is a form called fsubInvoiceDetails.

    Following this,
    i tried inserting the following code in the 'after update' event of the customerID look up in the main form entitled 'frmInvoice'.

    Forms!frmInvoice.fsubInvoiceDetails.cbxBookingID.R equery

    Unfortunately, an error message flashes up when trying to compilte:

    "...Application defined error."

    Any ideas?

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I mean the subform container control in which the form is found. What is name of the subform container control what is name of form held by the control? Look at the Name and SourceObject properties of the container control.

    You created a VBA procedure? You selected [Event Procedure] in the AfterUpdate event property? Click the ellipses (...) and that will take you to the procedure in VBA editor.
    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.

  11. #11
    tim_tims33 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    62
    Quote Originally Posted by June7 View Post
    I mean the subform container control in which the form is found. What is name of the subform container control what is name of form held by the control? Look at the Name and SourceObject properties of the container control.

    You created a VBA procedure? You selected [Event Procedure] in the AfterUpdate event property? Click the ellipses (...) and that will take you to the procedure in VBA editor.
    I'm still unsure what you mean by 'container'.

    There are two forms:
    form INVOICE
    and
    form fsubINVOICEdetails.

    The BookingID lookup is found in form fsubINVOICEdetails. So, is form fsubINVOICEdetails the container?

    Furthermore, if so, does the following VBA provide the solution?

    Forms!frmInvoice.fsubInvoiceDetails.cboBookingID.R equery


    where:
    frmInvoice is teh main form...
    fsubInvoiceDetails...is the subform...which contains the BookingID lookup
    cboBookingID is the name of the lookup.

    (I know how to apply a VBA procedure in the 'after update' event property)

    Sorry for my incompetence!

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Subforms are created by putting a subform containter control on a form. The container control has a SourceObject property. The source object can be a table, query, form, report. The container control 'holds' an object. I always name the container different from the object it holds. Click once on the 'subform', this selects the container and you will see its properties in the Properties dialog, click again and you have selected the object (or some part of) within the container and see its properties.

    If that clarifies, look at post 4 again for the suggested syntax.
    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.

  13. #13
    tim_tims33 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    62
    No...i've tried the following statement and it still doesn't work.

    Forms!frmInvoice.fsubInvoiceDetails.cboBookingID.r equery

    ...anyone have any other ideas? ...or have I got my syntax wrong?

    thanks

    tim

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    What is the name of the subform container control?

    Forms!frmInvoice.put name of subform container control here.Form.cbxBookingID.Requery
    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.

  15. #15
    tim_tims33 is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    62

    Thumbs up Solved:

    Quote Originally Posted by June7 View Post
    What is the name of the subform container control?

    Forms!frmInvoice.put name of subform container control here.Form.cbxBookingID.Requery
    Hi,

    That's it solved! Thanks very much... I tried a different computer and put in the same criteria as I previously posted ...and some reason it worked. My container was fsubInvoiceDetails.... but i am aware that this could have a different data source.

    Many thanks for your patience and help!

    tim

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

Similar Threads

  1. Link main form with subform
    By lizzywu in forum Forms
    Replies: 1
    Last Post: 11-18-2011, 03:22 PM
  2. Replies: 6
    Last Post: 11-17-2011, 10:50 PM
  3. Replies: 3
    Last Post: 11-16-2011, 01:56 PM
  4. Subform in a Tab Control on a Main form
    By jpkeller55 in forum Access
    Replies: 4
    Last Post: 01-08-2011, 12:31 PM
  5. Replies: 0
    Last Post: 08-17-2008, 12:19 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