Solved

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

Posted on 2013-01-04
11
1,535 Views
Last Modified: 2013-05-01
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
Comment
Question by:MCaliebe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +1
11 Comments
 
LVL 40

Expert Comment

by:als315
ID: 38744312
You should give more details about process. Usually one unbound checkbox in header is enough.
0
 

Author Comment

by:MCaliebe
ID: 38744349
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
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38744364
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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38744388
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
 
LVL 40

Expert Comment

by:als315
ID: 38744395
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
 
LVL 61

Accepted Solution

by:
mbizup earned 175 total points
ID: 38744418
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
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38744453
<It is clear now. >
Yes, for me to as well...

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

;-)

Jeff
0
 

Author Comment

by:MCaliebe
ID: 38744618
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
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 175 total points
ID: 38744633
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
 
LVL 61

Expert Comment

by:mbizup
ID: 38744643
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
 

Author Closing Comment

by:MCaliebe
ID: 38744684
Thanks to everyone for your input.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question