Solved

How to update a checkbox on exit

Posted on 2013-10-31
4
522 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 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

Industry Leaders: 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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

705 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