Free Lessons
Fast Tips
Topic Index
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
Home > Forums > Access
Back to Access Forum    Comments List
Change YesNo field Upload Images   Link   Email  
David Cummins       
2 months ago
I created an append query using the Yes/No field "Update" using Yes criteria. After the update, I want to reset the Yes/No field to "No". Can this be done with a Macro or VBA? Is there an example of the code to achieve this?

Many thanks!
Sami Shamma              
2 months ago
You can do just about anything with VBA; however, your question is not very clear.
Kevin Robertson            
2 months ago
If it is a field on the current form you could just say, for example:

IsActive = False

You can also do it with a little SQL.

CurrentDB.Execute "UPDATE CustomerT SET IsActive=False WHERE CustomerID=" & cboCustomers

Just change the Table name and field names for your needs.

As Sami said, the question isn't clear. We can't see what your working with so more details will be required for a more tailored response.

Check out the Access SQL Seminars
Part 2 covers Action Queries.
David Cummins       
2 months ago
Hi Sami, Kevin

This is for a Foster Youth Program where we recruit families to become foster parents.

The names of people interested in becoming foster parents are recorded in a InquiriesT. If they agree to become foster parents, they engage in training to become licensed. 'Once they are licensed the name of the foster family is then added to the FamilyHomesT via a an Append query. The InquriesT has a Yes/No field called 'Update'. Any 'Update" fields set to the Yes criteria are added to the FamilyHomesT.

I have this working well.

The problem is that the Append query will duplicate any family names in the FamilyHomesT when the 'Update" Yes/No field is set to yes.

I figured I can prevent duplications in the FamilyHomesT by automatically resetting the 'Update' field in the InquiresT to No, but I am not sure how to achieve this action.

FYI, data in the InquriesT has to be preserved for reporting reasons.

I hope this makes sense.
David Cummins       
2 months ago
Hi Kevin,

It turns out that SQL won't work for this particular situation so, I will have to learn some VBA here.
Sami Shamma              
2 months ago
Learning VBA last year was the best thing I've ever done. You will not regret it.
No one teaches it better than Richard.
David Cummins       
2 months ago
Sami, I tried VBA but it can't handle Boolean logic for Text box output. I want a text box to display "Yes" based on if the value of a Yes/No field is Null. It doesn't look like VBA can do that. I think only a Macro or expression builder will work for this so. I have brush up on Macro and expression builder.
Alex Hedley             
2 months ago
What VBA did you try?
Sami Shamma              
2 months ago
Field on form name: YesNoText
Files on Table name: YesNoField


if YesNoField= True then
   YesNoText = "Yes"
  YesNoText = "No"
David Cummins       
2 months ago

I tried a field level After Update script. After Update apparently does not work for Boolean logic, changing Yes/No values.  


your script worked. Thanks!

Now I have to figure out how to incorporate the VBA code into a Macro. can you recommend a Script editor app that can save a VBA script that can be imported into a Macro?
Alex Hedley             
2 months ago
> After Update apparently does not work for Boolean logic, changing Yes/No values.

What did you try, as this would work.

MS Access has a tool that can convert a Macro to VBA but not the other way round.
I'd strongly advise learning VBA, it might have a steep learning curve for you at first but it's so much easier to use and likely to find more people able to help
David Cummins       
2 months ago

I find Macros a quick way to achieve some simple functions, but I am signing up for Richard's VBA lesson's so, I will have more experience hopefully soon.

Kevin Robertson            
2 months ago
This is a pretty simple Macro to build. See my sample below.

I would attach it to the After Update event of the Check Box and the On Current event.
Kevin Robertson            
2 months ago

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.


The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
My Account
My Courses
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/15/2024 8:32:09 AM. PLT: 1s