Continuous forms : Controls Collection issue (1 Viewer)

GUIDO22

Registered User.
Local time
Today, 15:20
Joined
Nov 2, 2003
Messages
515
I have a continous form as shown attached. I have three checkboxes that display on each row - and a fourth checkbox on the right hand side that must ONLY display when the other three on the left have been checked.

To do this, I have a sub() call in AfterUpdate() on each of the 'three' checkboxes that logically ANDs the value of each, and assigns the result to the visible property for the fourth checkbox.

The problem with this arrangement, is that it either displays OR hides ALL of the instances of the fourth checkbox on the form as shown.. I am guessing I need to access the controls collection but aside from looking for the name of the fourth checkbox, am i also looking for a collection of 'fourth' checkboxes that I can iterate through to find the index of the one I specifically want to turn on /off....?
Any help would be appreciated. Thank you.
 

Attachments

  • access_query140122.jpg
    access_query140122.jpg
    284.2 KB · Views: 306

theDBguy

I’m here to help
Staff member
Local time
Today, 07:20
Joined
Oct 29, 2018
Messages
21,447
Hi. Not in front of a computer now, but could you check if Conditional Formatting applies to a checkbox?
 

GUIDO22

Registered User.
Local time
Today, 15:20
Joined
Nov 2, 2003
Messages
515
Hi. Not in front of a computer now, but could you check if Conditional Formatting applies to a checkbox?
No - only text boxes/labels...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:20
Joined
May 7, 2009
Messages
19,227
you can also do this.

bring your form in design view.
on the first 3 checkboxes, type this to the Click Event:

=fncShowChkPost()

now, add the code of function fncShowChkPost() to This Form:

Public Function fncShowChkPost()
Me![the4thCheckboxName].Visible = (((Me!chkbox1 + Me!chkBox2 + Me!chkBox3) * -1) = 3)
End Sub
 

GUIDO22

Registered User.
Local time
Today, 15:20
Joined
Nov 2, 2003
Messages
515
you can also do this.

bring your form in design view.
on the first 3 checkboxes, type this to the Click Event:

=fncShowChkPost()

now, add the code of function fncShowChkPost() to This Form:

Public Function fncShowChkPost()
Me![the4thCheckboxName].Visible = (((Me!chkbox1 + Me!chkBox2 + Me!chkBox3) * -1) = 3)
End Sub
.. thats much the same as what I have, the issue is that the visible status is set for ALL instance of the fourth checkbox... (see the pic)
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 10:20
Joined
May 21, 2018
Messages
8,516
The problem with this arrangement, is that it either displays OR hides ALL of the instances of the fourth checkbox on the form as shown.. I am guessing I need to access the controls collection but aside from looking for the name of the fourth checkbox, am i also looking for a collection of 'fourth' checkboxes that I can iterate through to find the index of the one I specifically want to turn on /off....
Not possible. There is no collection of individual controls, there is only one. On a continuous form there is only one set of controls and then each instance is "Painted" as the form loads. If you hide one you hide them all. Conditional format can kind of get around this because it works on the paint event. Each time a instance is painted it makes a formatting decision. On a form you can try to do this yourself on the details "on paint" event, but it usually only kind of works well. With conditional formatting you can set the forecolor and back color of the control to be the same color and it will appear to disappear. You would then need to fake a checkbox using a textbox and wingding font to make it look like a check. You then can fake this last checkbox and make it appear to hide.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:20
Joined
May 7, 2009
Messages
19,227
on contrary, since this is a Continuous form, it will Affect all other Rows.

you can simply leave the 4th checkbox visible, but disallow checking the 4th checkbox if the 3 others are not checked yet:

Private Sub check4_BeforeUpdate(Cancel As Integer)
Cancel = ((Me.check1 + Me.check2 + Me.check3) * -1) < 3
If Cancel Then Me.check4.Undo
End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 15:20
Joined
Feb 19, 2013
Messages
16,601
in a continuous form, hiding any control will hide it in all rows. checkboxes don't have conditional formatting so you can't 'hide' it by setting the colour to the same as the detail backcolor or disable it.

With regards a fake textbox as MajP suggests - see this link
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:20
Joined
May 7, 2009
Messages
19,227
using "hidden fake" checkbox, sooner or later the operator will know that there is a checkbox there.
if they accidentally/deliberately click on the "checkbox" area, it will get updated without being visible
and will get Posted accidentally/deliberately.

while disallow any click on it will guarantee that the records is not posted accidentally/deiberately.
 

GUIDO22

Registered User.
Local time
Today, 15:20
Joined
Nov 2, 2003
Messages
515
on contrary, since this is a Continuous form, it will Affect all other Rows.

you can simply leave the 4th checkbox visible, but disallow checking the 4th checkbox if the 3 others are not checked yet:

Private Sub check4_BeforeUpdate(Cancel As Integer)
Cancel = ((Me.check1 + Me.check2 + Me.check3) * -1) < 3
If Cancel Then Me.check4.Undo
End Sub
Hey Bro, that worked a treat.. thank you very much.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:20
Joined
May 7, 2009
Messages
19,227
Hey Bro, that worked a treat.. thank you very much.
there is another problem.
operator might click the post checkbox while on New record.
you cancel it also:


Private Sub Form_BeforeInsert(Cancel As Integer)
Call post_BeforeUpdate(Cancel)
End Sub

Private Sub post_BeforeUpdate(Cancel As Integer)
Cancel = ((Me.check1 + Me.check2 + Me.check3) * -1) < 3
If Cancel Then Me.post.Undo
End Sub
 

GUIDO22

Registered User.
Local time
Today, 15:20
Joined
Nov 2, 2003
Messages
515
Thanks, but i don't have this issue as the records on this dialog are created elsewhere ..
 

LarryE

Active member
Local time
Today, 07:20
Joined
Aug 18, 2021
Messages
578
Just create fields in your table with a Yes/No Data Type and bind the checkboxes on your form to those fields. Then, you can work with them individually on each record on the form.
 

Users who are viewing this thread

Top Bottom