Open Filtered Form with Where Condition

  • Thread starter Thread starter Doctor
  • Start date Start date
D

Doctor

I have the code below to open a form of contacts, and I want the button to
open the form only displaying active members, but it is only opening a blank
form (the bottom does say 1 of 1 Filtered).

The information that I want to test in my code is a check box.

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ChurchInformation"
DoCmd.OpenForm stDocName, WhereCondition:=ChurchCurrentCharter = True Or
ChurchActiveCharter = True

Any help would be tremendously appreciated.
 
The Where condition is a string. You need quotes:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ChurchInformation"
DoCmd.OpenForm stDocName, WhereCondition:= "ChurchCurrentCharter = True "
& _
"Or ChurchActiveCharter = True"

(Note that I used a line continuation character to put the condition on two
separate lines)
 
Thanks so much that did the trick.

Douglas J. Steele said:
The Where condition is a string. You need quotes:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ChurchInformation"
DoCmd.OpenForm stDocName, WhereCondition:= "ChurchCurrentCharter = True "
& _
"Or ChurchActiveCharter = True"

(Note that I used a line continuation character to put the condition on two
separate lines)
 
Back
Top