AllExperts > Using MS Access 
Search      
Using MS Access
Volunteer
Answers to thousands of questions
 Home · More Using MS Access Questions · Answer Library  · Encyclopedia ·
More Using MS Access Answers
Question Library

Ask a question about Using MS Access
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Scottgem
Expertise
I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience
I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

 
   

You are here:  Experts > Computing/Technology > Business Software > Using MS Access > Running a Query Based on Checkbox Results

Using MS Access - Running a Query Based on Checkbox Results


Expert: Scottgem - 7/9/2009

Question
Hi Scott!!  I'm sorry I keep coming back to you, I tried to find this answer, and couldn't.  Could be there, but there's a LOT of answers on here.

My next thing I want to do is this...

I'd like to have a form that lists numerous records.  And I guess I'd need to have a checkbox for each one too.

Basically I need to run an UPDATE query for each checkbox that has a tick in it.  So anything that has a checkbox gets updated.

I also would need to run an APPEND query to add an entry in a different table for each checkbox ticked.

Can I send these checkboxes to more than one query?  Very confused how I would do this!  

Thanks so much, you rock!!

Answer
No problem in coming back to me when you need help and can't find a similar question.

I need to clarify some things here. Is there no common criteria that can be used to select these records? Do you need the checkbox as the only way to select the record? If so, this is not difficult. You add a yes/no field to your table. Then check off the records you need act on. You then add a process selection command button with code like this:

Dim strSQL As String

strSQL = "UPDATE table SET field = value " & _
        "WHERE [selectfield] = True;"
CurrentDB.Execute strSQL

strSQL = "INSERT INTO table (field list) " & _
        "SELECT field list FROM table " & _
        "WHERE [selectfield] = True;"
CurrentDB.Execute strSQL

strSQL = strSQL = "UPDATE table SET selectfield = False;"
CurrentDB.Execute strSQL

The first SQL statement updates the table SETting the appropriate field to the appropriate value. The second statement appends the the field list from the table into your other table. The final statement resets the checkbox field.

Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.