Results 1 to 3 of 3
  1. #1
    RankSinatra is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Feb 2018
    Posts
    14

    Query criteria breaks parent/child relationships


    I have a form based on a query that selects cashiers by date their register is assigned and location they work. If I put "front" in the location criteria, it filters the results correctly. However, I want the date combo box on the form to only show the attendants that had registers on that specific selected date. So I have the combobox referenced in the query criteria for the operationaldate field as forms![parentform]![datecombobox]. This works until I close the form and reopen it, after which the subforms no longer update and the text boxes on them tell me I must input values for the fields that should be linked automatically to the comboboxes. If I delete the expression from the criteria, the subforms once again link as they are supposed to. Is there another way to have the comboboxes for the cashier's names and locations autoupdate based on the date value? Because otherwise it shows every cashier and every location for every date and that doesn't reflect the sign out records.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    you can only have the subforms work 1 way,
    either link the subtable to the cashier, or to the date.

    you wouldnt even NEED a subform. This would eliminate the subform errors you mentioned.
    Instead use a continuous form with all records, with combo boxes on the form header.
    pick a date to filter the records on the date.
    pick a cashier to filter the records on the cashier.

    build the 'where' clause by cycling thru all the controls....
    it executes afterupdate event
    if null, ignore.
    if not, apply.

    Code:
    sub cboDate_Afterupdate()
      FilterRecs
    end sub
    
    sub cboCashier_Afterupdate()
      FilterRecs
    end sub
    
    '----------------
    sub FilterRecs()
    '----------------
    dim sWhere as string 
    
    
    sWhere = "1=1"
    if not IsNUll(cboDate) then sWhere = sWhere & " and [Date]=#" & cboDate & "#"
    if not IsNUll(cboCashier) then sWhere = sWhere & " and [Cashier]='" & cboCashier & "'"
    
    
    If sWhere = "1=1" Then
      Me.FilterOn = False
    Else
      Me.Filter = sWhere
      Me.FilterOn = True
    End If
    end sub

  3. #3
    RankSinatra is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Feb 2018
    Posts
    14
    I was able to fix this issue by setting the criteria on the combobox queries instead of the underlying query. I'm dealing with a different problem now. I don't know if I should start a new thread or posted here, but at the risk of starting too many threads I'm just going to include it on this one. That is, until someone else tells me otherwise. The issue I'm having now is related to the table opened exclusively by another user error. I have two forms that reference the same sign out log table, one assigns new registers and the other one balances the old ones. I would like to do both actions simultaneously, signing out new tills while balancing the a.m. registers. However it will not let me have both forms open simultaneously. Is there a way around this? I'm not worried about over writing records because the sign out form only adds new records, it does not edit the old ones so I can't overwrite anything.

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

Similar Threads

  1. Replies: 7
    Last Post: 01-21-2014, 11:32 AM
  2. Replies: 3
    Last Post: 07-03-2013, 01:20 PM
  3. Replies: 4
    Last Post: 10-29-2012, 02:20 PM
  4. Replies: 0
    Last Post: 05-26-2010, 05:46 PM
  5. Parent/Child subform
    By Jerry8989 in forum Forms
    Replies: 1
    Last Post: 09-18-2009, 07:27 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