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

    Search date VBA but subform

    I have some forms that have date fields that I need to search between on the subform.

    The main form gets opened by a button with



    Code:
    DoCmd.OpenForm "frmBookingEdit", , , "BookingDate BETWEEN #" & Me.txtFromDate & "# AND #" & Me.txtUntilDate & "#"
    aside from getting the concatenation wrong (My first guess) is the form searchable if the date fields are in the subform?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Data in the subform has no bearing on filtering the main form recordset. Child does not dictate parent.
    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
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    One way around is to create and apply a filter to main form using the "linked master field" based on the dates in subform. In this case, records from main form matching the date criteria of subform will be displayed.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Amrut, how do you propose that should happen? Yes, subform records will synchronize with the main form record but the date values are in the subform, not the main form, therefore the main form cannot be filtered on the dates.
    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
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Only the corresponding records of main form wherein the subform has atleast one record matching the date criteria will be displayed.
    To create the filter, loop through the child table records between the required dates and create the filter using linked ChildField.

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

Similar Threads

  1. Replies: 3
    Last Post: 09-23-2013, 10:43 PM
  2. Replies: 3
    Last Post: 09-11-2013, 09:49 AM
  3. Replies: 3
    Last Post: 08-22-2012, 03:28 AM
  4. Replies: 7
    Last Post: 08-08-2012, 03:28 PM
  5. Search a Subform
    By libraccess in forum Forms
    Replies: 2
    Last Post: 05-16-2012, 07:07 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