Solved How to add a checkbox on a Continuous Form (1 Viewer)

Pop_Access

New member
Local time
Yesterday, 18:58
Joined
Aug 19, 2019
Messages
23
Hi;
I am trying to add a checkbox on a continuous form in order to select "employees" that I will send an Email to them.

the data (on the continuous form) comes from query, now if I checked or unchecked the checkbox on the form detail, all of them will have the same behavior.

I don't want to add (yes/no) field on the table because I don't need to save the data of (yes/no).

Thank You
 

Attachments

  • 2021-01-10 at 3.42.24 PM.zip
    1.5 MB · Views: 26

bob fitz

AWF VIP
Local time
Today, 02:58
Joined
May 23, 2011
Messages
4,224
AFAIK the only way to do this would be by adding a field to the table.
I don't want to add (yes/no) field on the table because I don't need to save the data of (yes/no).
But you do need to save it unless you want to write each email while in each of the records.
You could have a sperate table in which you save the PK of the employee but it would need to be saved somewhere until the email is sent
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:58
Joined
May 21, 2018
Messages
4,778
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.
You could simplify that a lot for your need since you are only selecting and not doing it in a continuous form..
 

arnelgp

error reading drive A:
Local time
Today, 09:58
Joined
May 7, 2009
Messages
12,059
maybe this sample will help you.
 

Attachments

  • RecordSelectorClick.accdb
    540 KB · Views: 34

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 21:58
Joined
May 21, 2018
Messages
4,778
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.
 

Attachments

  • CheckUncheckMultiSelect V2.accdb
    1.7 MB · Views: 32

Pop_Access

New member
Local time
Yesterday, 18:58
Joined
Aug 19, 2019
Messages
23
AFAIK the only way to do this would be by adding a field to the table.

But you do need to save it unless you want to write each email while in each of the records.
You could have a sperate table in which you save the PK of the employee but it would need to be saved somewhere until the email is sent
Thank you for your response;

The Email address is already available in the data, any way, I attached a small video from the database
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 11:58
Joined
Jan 20, 2009
Messages
12,268
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.
Local time
Yesterday, 21:58
Joined
May 21, 2018
Messages
4,778
@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.
 

Attachments

  • ClassCheckBox.accdb
    1.3 MB · Views: 32

Sun_Force

Member
Local time
Today, 10:58
Joined
Aug 29, 2020
Messages
186
@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.
 

Pop_Access

New member
Local time
Yesterday, 18:58
Joined
Aug 19, 2019
Messages
23
@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.
@MajP you did a great jo, but the "Add All" Not working all the time. :)
 

arnelgp

error reading drive A:
Local time
Today, 09:58
Joined
May 7, 2009
Messages
12,059
with sample emailing.
 

Attachments

  • FakeCheckbox.accdb
    1 MB · Views: 34

Zedster

Registered User.
Local time
Today, 02:58
Joined
Jul 2, 2019
Messages
125
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.
 

Users who are viewing this thread

Top Bottom