Code to untick box on exit (1 Viewer)

Aimn_4U

Registered User.
Local time
Today, 07:44
Joined
May 14, 2019
Messages
33
Hi All,

I have a "deactivation" tick box on one of my forms, when this box is ticked a sub form appears which requires you to put in the deactivation date etc.

However, as sometimes this can be ticked by mistake or admin makes an error, if they press the exit button on the subform i would like the box to untick automatically on the original form.

could someone please help me out with a code and where I would possibly put the code (on the form or subform ?).

Thank you in advance.
 

nhorton79

Registered User.
Local time
Today, 11:44
Joined
Aug 17, 2015
Messages
147
My thought would be put the code on the subforms cancel button on_click event.

Would be something like:

Code:
Forms!Mainform!ControlName = False
DoCmd.Close acForm, Mainform
DoCmd.Close acForm, Me.Name

Without knowing exactly how your forms are handled on close, field names and form names it’s a little bit hard to give exact code but hopefully this might help you get moving along.

The idea being:
1. Set the control/field name while the main form is still about.
2. Close the main form
3. Close the ‘exit/date’ form




Sent from my iPhone using Tapatalk
 

June7

AWF VIP
Local time
Yesterday, 15:44
Joined
Mar 9, 2014
Messages
5,463
It would be harder to 'accidentally' tick a yes/no field if you used a combobox instead of checkbox.
 

isladogs

MVP / VIP
Local time
Today, 00:44
Joined
Jan 14, 2017
Messages
18,209
@aimn_4u
I've deleted your duplicate post on this topic.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:44
Joined
Oct 29, 2018
Messages
21,447
Hi. Another idea is to ask the user to confirm that they really meant to check the box before opening the subform.
 

Micron

AWF VIP
Local time
Yesterday, 19:44
Joined
Oct 20, 2018
Messages
3,478
Hi. Another idea is to ask the user to confirm that they really meant to check the box before opening the subform.
That's just the sort of thing that would drive me crazy. I'd be saying "YES, FOR THE UMPTEENTH TIME, YES!!"
Maybe a prompt if the subform is visible but doesn't have data in any field and the main form checkbox is clicked. Could be IF Me.Dirty = False on the subform, unless data has been entered via code already.

I don't see why any exit or close buttons would be on the subform rather than the main form, and I don't see the point in a combo box for a yes/no or True/False situation. I also don't see the point in unchecking the box if the form(s) are being closed as it will be unchecked next time it opens anyway, unless maybe it is bound - which was not stated.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:44
Joined
Oct 29, 2018
Messages
21,447
That's just the sort of thing that would drive me crazy. I'd be saying "YES, FOR THE UMPTEENTH TIME, YES!!"
Maybe a prompt if the subform is visible but doesn't have data in any field and the main form checkbox is clicked. Could be IF Me.Dirty = False on the subform, unless data has been entered via code already.

I don't see why any exit or close buttons would be on the subform rather than the main form, and I don't see the point in a combo box for a yes/no or True/False situation. I also don't see the point in unchecking the box if the form(s) are being closed as it will be unchecked next time it opens anyway, unless maybe it is bound - which was not stated.
Good point!
 

Aimn_4U

Registered User.
Local time
Today, 07:44
Joined
May 14, 2019
Messages
33
That's just the sort of thing that would drive me crazy. I'd be saying "YES, FOR THE UMPTEENTH TIME, YES!!"
Maybe a prompt if the subform is visible but doesn't have data in any field and the main form checkbox is clicked. Could be IF Me.Dirty = False on the subform, unless data has been entered via code already.

I don't see why any exit or close buttons would be on the subform rather than the main form, and I don't see the point in a combo box for a yes/no or True/False situation. I also don't see the point in unchecking the box if the form(s) are being closed as it will be unchecked next time it opens anyway, unless maybe it is bound - which was not stated.

Thank you very much. The data has not been entered Via a code already.
Therefore if I put the IF Me.Dirty=False on the exit button of the subform what would be the next part of the code ?

Then ??

Sorry I am fairly new to all this.
 

June7

AWF VIP
Local time
Yesterday, 15:44
Joined
Mar 9, 2014
Messages
5,463
I have used combobox for Yes/No. User types Y or N. Users often think they have to use mouse to change checkbox (maybe not aware the space bar would do that). Can't resize checkbox. Removing hand from keyboard and mousing the cursor to target that little box is annoying and slows data entry. I try to build forms so users can do everything from keyboard as intuitively as possible.
 

Micron

AWF VIP
Local time
Yesterday, 19:44
Joined
Oct 20, 2018
Messages
3,478
Removing hand from keyboard and mousing the cursor to target that little box is annoying
Amazing what frustrates or annoys some people.

So they don't want to tab to the box and press the space bar to set the checkbox? Or would that not be intuitive enough?
 

Micron

AWF VIP
Local time
Yesterday, 19:44
Joined
Oct 20, 2018
Messages
3,478
Therefore if I put the IF Me.Dirty=False on the exit button of the subform what would be the next part of the code ?
Try
Code:
If Me.Dirty = False Then
  Me.Parent.NameOfYourCheckbox = False
End If
Not that I suppose it really matters, but I don't see the sense it this. Then again, you haven't explained much of how these forms are used.
 

June7

AWF VIP
Local time
Yesterday, 15:44
Joined
Mar 9, 2014
Messages
5,463
I already stated I think users often not aware that space bar can change the checkbox. I personally don't like to go back and forth between keyboard and mouse on a data entry form. I just want to tab/enter to progress through controls and type input. If every input could be point and click that would be fine but I have yet to see a database that can be done with.

I've seen enough accidental clicks on checkbox (in spite of tiny size); usually user is just clicking anywhere in record to select it and if they hit the checkbox, it changes value, especially easy to do on Datasheet view.

The OP brought up issue of 'accidental click', just offering an option.
 

Users who are viewing this thread

Top Bottom