Link to home
Start Free TrialLog in
Avatar of MCaliebe
MCaliebeFlag for United States of America

asked on

Select All records in a filtered continuous form selection from single check box

Good morning,

I have a working form which I use to filter data and update various fields on a form.  I want the option to "select all" records which would be populated in the detail of the form.

Does the underlying table have to have a check box field for me to perform a "select all" or can the check box on the detial line be some kind of unbound field...something that an update query could still refer to?

I hope I am clear on my issue.  If not, please ask for clarification and I'll do what I can to accomodate.

Thanks,
MC
Avatar of als315
als315
Flag of Russian Federation image

You should give more details about process. Usually one unbound checkbox in header is enough.
Avatar of MCaliebe

ASKER

I have an unbound check box in the header of the form..which we call chk_SelectAll.  I would like it, when clicked, to Select or Deselct all records in the form detail.  i will need to add a check box to each detail record so an update query could make changes based on whether or not the detail check box is true or false.

Does the check box in the detail need to be part of the table being updated or can it remain unbound in the detail.

I know how to fire an update query from an unbound check box in the header to update all records in a table to true, which should in turn repopulate a check box in the detail of the form to true...provided it is linked to that table field.

I just imagine that there should be a way to flag which records in the detail need to be updated without actually having to first rewrite a true/false field in each record of the table.
You did not state how you were filtering this form, but in the most basic sense you can cancel out any filters with code like this:

Me.Filter=""
Me.FilterOn=False

...and this will display all records

Now, if the Recordsouce of the form itself is filtering the records, you may want to post a simple sample of this database, to avoid confusion.

JeffCoachman
We still need to know how you are filtering the form.

This is why a sample database makes things easier to understand.

Sample database notes:
1. Back up your database(s).
2. Combine the front and back ends into one database file.
3. Remove any startup options, unless they are relevant to the issue.
4. Remove any records unless they are relevant to the issue.
5. Delete any objects that do not relate directly to the issue.
6. Remove any references to any "linked" files (files outside of the database, Images, OLE Files, ...etc)
7. Remove any references to any third party Active-x Controls (unless they are relevant to the issue)
8. Remove, obfuscate, encrypt, or otherwise disguise, any sensitive data.
9. Unhide any hidden database objects
10. Compile the code. (From the VBA code window, click: Debug-->Compile)
11. Run the compact/Repair utility.
12. Remove any Passwords and/or security.
13. If a form is involved in the issue, set the Modal and Popup properties to: No
    (Again, unless these properties are associated with the issue)
14. Post the explicit steps to replicate the issue.
15. Test the database before posting.

In other words, ...post a database that we can easily open and immediately see and/or troubleshoot the issue.
And if applicable, also include a clear graphical representation of the *Exact* results you are expecting, based on the sample data.

JeffCoachman
It is clear now. Unbound box in detail will not be related to your record, so you should have field in table (in separate table, may be).
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<It is clear now. >
Yes, for me to as well...

it seems like mbizup has got you covered here...

;-)

Jeff
Thank you for everyones advice.  My initial question, do I have to have a bound check box in the deteail has been answered completely.  Because I wanted my selections limited to the filtered items, I am using the following code to fire off my slection properties.

Private Sub Chk_Select_All_Click()
Dim stSQL As String

'If gcfHandleErrors Then On Error GoTo PROC_ERR


If Not Me.txt_filterStr = "" Then


    If Me.chk_select_all = True Then
        DoCmd.SetWarnings False
        stSQL = "UPDATE (tbl_EOS_Rank INNER JOIN TBL_OAUSER_INV_MASTER " & _
                "ON tbl_EOS_Rank.ITEM_SEQUENC_NO = TBL_OAUSER_INV_MASTER.ITEM_SEQUENC_NO) LEFT JOIN tbl_Excl_Item_Numbers " & _
                "ON TBL_OAUSER_INV_MASTER.ITEM_SEQUENC_NO = tbl_Excl_Item_Numbers.ITEM_SEQUENC_NO SET tbl_EOS_Rank.Select = True " & _
                "WHERE " & Me.txt_filterStr
                
        DoCmd.RunSQL stSQL
        Me.Refresh
        
        Else
        stSQL = "UPDATE (tbl_EOS_Rank INNER JOIN TBL_OAUSER_INV_MASTER " & _
                "ON tbl_EOS_Rank.ITEM_SEQUENC_NO = TBL_OAUSER_INV_MASTER.ITEM_SEQUENC_NO) LEFT JOIN tbl_Excl_Item_Numbers " & _
                "ON TBL_OAUSER_INV_MASTER.ITEM_SEQUENC_NO = tbl_Excl_Item_Numbers.ITEM_SEQUENC_NO SET tbl_EOS_Rank.select = False " & _
                "WHERE " & Me.txt_filterStr
                
        DoCmd.RunSQL stSQL
        Me.Refresh
        DoCmd.SetWarnings True
    End If
Else
MsgBox ("Please apply filter before selecting ALL items")
Me.chk_select_all = False

End If

'PROC_ERR:
  'MsgBox "Error: (" & Err.Number & ") " & Err.Description, vbCritical

End Sub

Open in new window


My only issue at this time is I get a write failure/conflict if I do a Select All, and then go into the detail and deselect some items.

Is there a way to prevent this?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also... if you are using SQL Server for a back-end, ensure that the isSelected Bit field has its Allow Nulls property set to False and has a default value of (0).
Thanks to everyone for your input.