Solved How to add a checkbox on a Continuous Form

Pop_Access

Member
Local time
Today, 10:00
Joined
Aug 19, 2019
Messages
66
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

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

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
 
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.
 
@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

@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 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. :)
 
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.
 
i think i already fixed that on post #14.
 

Users who are viewing this thread

Back
Top Bottom