Solved

How to update a checkbox on exit

Posted on 2013-10-31
4
470 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
  • 2
  • 2
4 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
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 119

Accepted Solution

by:
Rey Obrero earned 500 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now