Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-01-04
11
Medium Priority
?
1,660 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
  • 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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 700 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 700 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

772 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