• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1748
  • Last Modified:

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
0
MCaliebe
Asked:
MCaliebe
  • 3
  • 3
  • 3
  • +1
2 Solutions
 
als315Commented:
You should give more details about process. Usually one unbound checkbox in header is enough.
0
 
MCaliebeAuthor Commented:
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.
0
 
Jeffrey CoachmanMIS LiasonCommented:
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
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
Jeffrey CoachmanMIS LiasonCommented:
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
0
 
als315Commented:
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).
0
 
mbizupCommented:
For what you are describing, the checkbox in your detail section needs to be bound to a field in the underlying table.  (Create a boolean field called isSelected)

This will select all records in your subform's recordset, regardless of filtering.  I'm assuming the code will be placed behind your unbound "Select All" checkbox on the main form.

Dim rs as DAO.recordset
SET rs = Me.SubformControlName.Form.recordsetClone
if rs.recordcount = 0 then 
     msgbox "No records present"
     exit sub
end if
do until rs.eof

rs.edit
rs!isSelected = true
rs.update
rs.movenext

Loop
set rs = nothing
 Me.SubformControlName.Form.Requery

Open in new window

0
 
Jeffrey CoachmanMIS LiasonCommented:
<It is clear now. >
Yes, for me to as well...

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

;-)

Jeff
0
 
MCaliebeAuthor Commented:
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?
0
 
mbizupCommented:
The Select All checkbox in your main form should be *unbound*.  You only need a bound checkbox in the detail section.

Also add this line to the Enter event of your subform control:

Me.Refresh
0
 
mbizupCommented:
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).
0
 
MCaliebeAuthor Commented:
Thanks to everyone for your input.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

  • 3
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now