[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to update a checkbox on exit

Posted on 2013-10-31
4
Medium Priority
?
528 Views
Last Modified: 2013-11-04
I have a form that I have attached here that we will call Form1. On this form I can check the assigned checkbox or uncheck it. I also have a second form that is open that I call Form2

I need to add an action that does the following

onExit
if Forms!Form2!txtField1 is null

unselect all the "Assigned" checkboxes on Form1

Else
Just leave the checkboxes I have selected checked as they are

I'm a bit rusty on VBA. Much appreciated
This is Form1
Form1
0
Comment
Question by:damixa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39615208
try using the Unload event of form2


private sub form_Unload(cancel as Integer)
on error resume next
If IsNull(Me.txtField1) then
     with forms!form1.Recordset
          do until .EOF
          .edit
          !Assigned = 0
          .update
          .moveNext
          loop
     end with
end If
end sub
0
 

Author Comment

by:damixa
ID: 39615358
Hi Capricorn,
Thanks for your help.

one tiny problem.

lets say I have checked
record1
record2
record 3

when I try to close the form, if I have selected record2 for example it will uncheck everything starting at record2, so the record 1 will still be selected and assiged.

is there a way I can add some code to start at the begining of the form and not at the record I have selected?

thanks again, this has beeen very helpful
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 39615528
revise the codes

private sub form_Unload(cancel as Integer)
on error resume next
If IsNull(Me.txtField1) then
     with forms!form1.Recordset
         
          .movefirst      'add this line

          do until .EOF
          .edit
          !Assigned = 0
          .update
          .moveNext
          loop
     end with
end If
end sub
0
 

Author Closing Comment

by:damixa
ID: 39622050
thanks,
as always amazing work
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question