Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2009
    Posts
    223

    Unanswered: Criteria in a Query - CheckBox

    I want to put Criteria in a Simple Query.

    The criteria I want is that

    If Checkbox is True, then ‘return this record in the query’.
    But if Checkbox is False, then DO NOT return this record in the query.

    So far, I get stuck after the following:-

    [Forms]![Report 3 Form]![Swimming Pool 2]

    Does anybody have any suggestions??

    Cheers.
    Last edited by reddevil1; 08-10-11 at 15:40.

  2. #2
    Join Date
    Jan 2009
    Location
    Kerala, India
    Posts
    183
    Refresh the Form while setting the checkbox value on the Click Event procedure to update that change in the Query criteria column:

    Code:
    Private Sub chkBox_Click()
       Me.Refresh
    End Sub
    www.MsAccessTips.com (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

  3. #3
    Join Date
    Nov 2009
    Posts
    223
    Hi apr pillai,

    Sorry, but I am not quite with you there?

    I am trying to put code in the Criteria field of a Query...something like

    Iif([Forms]![Report 3 Form]![Swimming Pool 2]=True,then return this record, else do NOT return this record)

    I do not understand why the Form may need refreshing??

  4. #4
    Join Date
    Jan 2009
    Location
    Kerala, India
    Posts
    183
    When you open the Form with [Swimming Pool 2] status (True or False) will be visibile to the Query and you may get the corresponding result from the Query.

    But, after opening the form if you change the status (like put a check mark, when there was no check mark on the form) then that change may not immediately reflect in the under lying Query, with the criteria reference to the form control, unless you execute a current Form Refresh Action or save the current record (Ctrl+S or Save action from Menu) or move from the current record to the next etc.

    I hope this will make more clear.
    www.MsAccessTips.com (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

  5. #5
    Join Date
    Nov 2009
    Posts
    223
    Ah, ok. That is more clear to me now.

    However, after the client has "ticked" the boxes, the [Report 3 Form] will stay the same until after the Query (or Queries) have been executed.

    So, I guess no need to referesh the Form???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •