?
Solved

How to update a checkbox on exit

Posted on 2013-10-31
4
Medium Priority
?
524 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses
Course of the Month13 days, 3 hours left to enroll

777 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