Access Vba Continuous Form Checkbox No Field in Source
MajP
You've got your good things, and you've got mine.
- #3
If you do not want to add the field then would a multi select listbox be ok? If you really want checks you can do it by creating an ADO in memory recordset. I do this here.
Faking a Multi Value Field
I have seen a few posts lately on people wanting to use multi valued fields. Most Access developers steer away from them and build their own related tables. Although they are properly normalized and work well, they can get very confusing even if you know the ins and outs. I wanted to see if I...
www.access-programmers.co.uk
You could simplify that a lot for your need since you are only selecting and not doing it in a continuous form..
arnelgp
..forever waiting... waiting for jellybean!
- #4
maybe this sample will help you.
-
RecordSelectorClick.accdb
540 KB · Views: 152
MajP
You've got your good things, and you've got mine.
- #5
The first link I posted showed this using an ADO in memory recordset, @arnelgp demoed with a continuous form, and this version demos the techniques using a standard multi select listbox.
-
CheckUncheckMultiSelect V2.accdb
1.7 MB · Views: 379
arnelgp
..forever waiting... waiting for jellybean!
- #7
another sample with Fake checkbox.
-
FakeCheckbox.zip
112.6 KB · Views: 348
- #8
The disconnected ADO recordset is the way to go. However MajP's Multiselect demo is not quite what was asked for.
Create a table with one Boolean field and insert a single record with whatever value you want to be the default on your form.
Build a query with this table and your source data in a Cartesian Join.
Use this query to create an ADO Recordset.
Disconnect the recordset by making its ActiveConnection propert equal Nothing. (Despite the ActiveConnection being an Object don't use Set)
Set the Recordset Property of the form to the disconnected recordset.
The ControlSouorce of the checkbox control on the form is the Boolean field in the recordset.
Once the records have been selected you need to loop though the recordset to process them.
MajP
You've got your good things, and you've got mine.
- #10
@arnelgp gave me an idea. This is pretty slick because I had not thought of doing this before. It is pretty good in that you can turn any unbound checkbox on a continuous form into a selector with minimal code.
Here is the whole code
Code:
Dim PersonnelSelector As New Record_Selector Private Sub Form_Load() Me.ID.SetFocus PersonnelSelector.Initialize Me.chkSelected, "ID", "ID" End Sub Public Function IsSelected(ID As Long) As Boolean IsSelected = PersonnelSelector.InSelection(ID) End Function The only big issues is that the checbox once the control is calculated does not fire a on click or update event. I had to use the focus instead. This means that you have to pass a control to take the focus after clicking. This looks and acts like a real checkbox. The class does all the work.
-
ClassCheckBox.accdb
1.3 MB · Views: 372
- #11
@arnelgp gave me an idea. This is pretty slick because I had not thought of doing this before. It is pretty good in that you can turn any unbound checkbox on a continuous form into a selector with minimal code.
Here is the whole code
@MajP Can you do something with screen flickering? When I click any checkboxes (in your form), for a second all are ticked, then all are unticked then the one I clicked is ticked. I tried to add a screenupdating = false, but still the same.
arnelgp
..forever waiting... waiting for jellybean!
- #14
with sample emailing.
-
FakeCheckbox.accdb
1 MB · Views: 211
- #16
another sample with Fake checkbox.
Thank you for that arnelgp it provides good ideas for the future. One observation though, when I check number 13 it also checks 3 number 14 it also checks 4 etc. So four end up being highlighted, but when I filter it only filters for 13 & 14.
arnelgp
..forever waiting... waiting for jellybean!
- #17
i think i already fixed that on post #14.
- #18
i think i already fixed that on post #14.
OK thanks, that is the one I didn't download and look at, so I will do so now.
Source: https://www.access-programmers.co.uk/forums/threads/how-to-add-a-checkbox-on-a-continuous-form.315623/
0 Response to "Access Vba Continuous Form Checkbox No Field in Source"
Post a Comment