Open Filtered Form with Where Condition

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.
 
D

Douglas J. Steele

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)
 
D

Doctor

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top