Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-09-2019, 12:10 AM   #1
Aimn_4U
Newly Registered User
 
Join Date: May 2019
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Aimn_4U is on a distinguished road
Code to untick box on exit

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.

Aimn_4U is offline   Reply With Quote
Old 09-09-2019, 12:24 AM   #2
nhorton79
Newly Registered User
 
Join Date: Aug 2015
Posts: 108
Thanks: 12
Thanked 13 Times in 13 Posts
nhorton79 is on a distinguished road
Re: Code to untick box on exit

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
nhorton79 is offline   Reply With Quote
Old 09-09-2019, 12:27 AM   #3
June7
AWF VIP
 
June7's Avatar
 
Join Date: Mar 2014
Location: The Great Land
Posts: 2,401
Thanks: 0
Thanked 559 Times in 555 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Code to untick box on exit

It would be harder to 'accidentally' tick a yes/no field if you used a combobox instead of checkbox.

__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is offline   Reply With Quote
Old 09-09-2019, 12:50 AM   #4
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 10,939
Thanks: 114
Thanked 2,991 Times in 2,720 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
Re: Code to untick box on exit

@aimn_4u
I've deleted your duplicate post on this topic.
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin (Mendip Data Systems)
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Old 09-09-2019, 04:25 AM   #5
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,706
Thanks: 57
Thanked 1,259 Times in 1,240 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Code to untick box on exit

Hi. Another idea is to ask the user to confirm that they really meant to check the box before opening the subform.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 09-09-2019, 10:32 AM   #6
Micron
AWF VIP
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 1,049
Thanks: 10
Thanked 208 Times in 197 Posts
Micron has a spectacular aura about Micron has a spectacular aura about
Re: Code to untick box on exit

Quote:
Originally Posted by theDBguy View Post
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.
__________________
Sometimes I just roll my eyes out loud...
Windows 10; Office 365 (Access 2016)
Micron is offline   Reply With Quote
Old 09-09-2019, 10:42 AM   #7
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,706
Thanks: 57
Thanked 1,259 Times in 1,240 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Code to untick box on exit

Quote:
Originally Posted by Micron View Post
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!

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 09-09-2019, 05:37 PM   #8
Aimn_4U
Newly Registered User
 
Join Date: May 2019
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Aimn_4U is on a distinguished road
Re: Code to untick box on exit

Quote:
Originally Posted by Micron View Post
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.
Aimn_4U is offline   Reply With Quote
Old 09-09-2019, 06:01 PM   #9
June7
AWF VIP
 
June7's Avatar
 
Join Date: Mar 2014
Location: The Great Land
Posts: 2,401
Thanks: 0
Thanked 559 Times in 555 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Code to untick box on exit

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.
__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is offline   Reply With Quote
Old 09-09-2019, 07:34 PM   #10
Micron
AWF VIP
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 1,049
Thanks: 10
Thanked 208 Times in 197 Posts
Micron has a spectacular aura about Micron has a spectacular aura about
Re: Code to untick box on exit

Quote:
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 is offline   Reply With Quote
Old 09-09-2019, 08:15 PM   #11
Micron
AWF VIP
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 1,049
Thanks: 10
Thanked 208 Times in 197 Posts
Micron has a spectacular aura about Micron has a spectacular aura about
Re: Code to untick box on exit

Quote:
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.
Micron is offline   Reply With Quote
Old 09-09-2019, 08:18 PM   #12
June7
AWF VIP
 
June7's Avatar
 
Join Date: Mar 2014
Location: The Great Land
Posts: 2,401
Thanks: 0
Thanked 559 Times in 555 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Code to untick box on exit

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.

__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pop up Exited without completion, untick check Box Aimn_4U Modules & VBA 4 05-28-2019 07:25 PM
password to untick checkbox james_IT Forms 8 10-15-2010 02:03 PM
Exit Code wop0703 Forms 2 06-15-2005 03:58 PM
Run Code on MSaccess exit Treason General 3 03-10-2003 10:26 AM
Exit Code Dina01 Modules & VBA 1 09-02-2002 11:37 AM




All times are GMT -8. The time now is 03:36 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World