Can wherecondition in Docmd.OpenForm be a boolean value?

Television

Registered User.
Local time
Tomorrow, 01:26
Joined
May 15, 2013
Messages
31
Greetings again!

One quick question: Can in function Docmd.OpenForm its wherecondition be a boolean value (true/false)? I try to make button to open a new form on a click and show only records that are True in certain yes/no field. I have tried several solutions but nothing works then I thought that maybe boolean is not a valid datatype for wherecondition and cant find answer to that question anywhere. Below is one experiment for solution:
Code:
DoCmd.OpenForm ("FeatureLocusFormForSearch",,,"DecorativeElements =" True)

Thank you!

Television
 
You can use boolean. Try:
DoCmd.OpenForm ("FeatureLocusFormForSearch",,,"[DecorativeElements] = True")
 
You can use boolean. Try:
DoCmd.OpenForm ("FeatureLocusFormForSearch",,,"[DecorativeElements] = True")

Unfortunately this code returns also a syntax error :(. Any ideas for correct syntax?

Television
 
Make sure that the Field you are applying the condition to is included in the Recordsource of the Form.. Also make sure that the field's data type is actually Yes/No in the table design..
Code:
DoCmd.OpenForm FormName:="FeatureLocusFormForSearch", WhereCondition:="DecorativeElements = True"
 
Make sure that the Field you are applying the condition to is included in the Recordsource of the Form.. Also make sure that the field's data type is actually Yes/No in the table design..
Code:
DoCmd.OpenForm FormName:="FeatureLocusFormForSearch", WhereCondition:="DecorativeElements = True"
Works now! Though I am curious why this code works but above one doesn't. Whats the difference between those two?

Thanks again!

Television
 
Main reason was because, the DoCmd.OpenForm function when using parentheses.. A detailed description on when to use brackets is available HERE.
 

Users who are viewing this thread

Back
Top Bottom