Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 19th, 2005, 12:29 PM
Registered User
 
Join Date: Feb 2005
Location: , , United Kingdom.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Checkbox problem

I have a search form with 21 check boxes on, I have to perform a search depending on which check box has been checked. There can be any number of boxes checked.

My problem is, how do I work out which box or boxes have been checked and pass the results to the SearchResults form?
Regards
peter

Reply With Quote
  #2 (permalink)  
Old February 19th, 2005, 09:18 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi peter,

Have a peak at:

http://p2p.wrox.com/topic.asp?TOPIC_ID=25668

You might find it useful. Its how I routinely do multiple-parameter searches. The search form builds the appropriate WhereCondition string in code, stores it in the variable strWhereCondition, then opens a search results form filtered by the WhereCondition.

DoCmd.OpenForm FormName:="frmSearchResults", WhereCondition:=strWhereCondition

To add checkbox criteria to the WhereCondition building code, add a parameter like:

  '-----------------------------------------------------------------
  ' 5. Build BatteriesIncluded parameter
  '-----------------------------------------------------------------

    If Me!chkBatteriesIncluded Then
        If IsNothing(strWhereCondition) Then
            strWhereCondition = "([BatteriesIncluded] Is Not Null)"
        Else
            strWhereCondition = strWhereCondition & " AND ([BatteriesIncluded] Is Not Null)"
        End If
    End If

HTH,

Bob

Reply With Quote
  #3 (permalink)  
Old February 19th, 2005, 09:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Or you might need:

If Me!chkBatteriesIncluded Then
        If IsNothing(strWhereCondition) Then
            strWhereCondition = "(Not [BatteriesIncluded])"
        Else
            strWhereCondition = strWhereCondition & " AND (Not [BatteriesIncluded])"
        End If
End If

or

If Me!chkBatteriesIncluded Then
        If IsNothing(strWhereCondition) Then
            strWhereCondition = "[BatteriesIncluded]"
        Else
            strWhereCondition = strWhereCondition & " AND [BatteriesIncluded]"
        End If
End If

If BatteriesIncluded is a boolean (Yes/No) field, the first snippet above would fulfill a request for a checkbox labeled:

"Don't list products that include batteries"

In my previous post, BatteriesIncluded would be a text field in your data source that stores the type of batteries included. So:

 If Me!chkBatteriesIncluded Then
        If IsNothing(strWhereCondition) Then
            strWhereCondition = "([BatteriesIncluded] Is Not Null)"
        Else
            strWhereCondition = strWhereCondition & " AND ([BatteriesIncluded] Is Not Null)"
        End If
    End If

would fulfill a request for a checkbox labeled:

"List all products that include batteries" (i.e., the BatteriesIncluded field isn't null).

It all depends on what type of data your check boxes indicate should be included in the query.

HTH,

Bob









Reply With Quote
  #4 (permalink)  
Old February 20th, 2005, 05:17 AM
Registered User
 
Join Date: Feb 2005
Location: , , United Kingdom.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok Bob
thanks for the quick reply, I'll give it a try..

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
multi checkbox problem deean Classic ASP XML 0 June 30th, 2008 12:43 AM
Checkbox indeterminate problem (I think) irishlad67 VB Databases Basics 2 March 30th, 2008 12:35 PM
checkbox problem sarvesh189 ADO.NET 1 March 21st, 2005 03:44 AM
CheckBox Insert Problem blink Classic ASP Databases 1 September 4th, 2003 12:34 PM



All times are GMT -4. The time now is 02:18 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.