Expression Builder Problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a conditional statement inside a macro so that a form
is only opened if this condition is met. However, even though my expression
is correct in expression builder I am told later when I run the application
that I am using a function that Access does not recognize. Basically, I want
a form to open if the results from a query are greater than zero.


I have tried:
if( Count ( [Buildings (by plat/lot)]![plat #] > 0) )


and other various combinations but no luck! Any insight would be greatly
appreciated!
 
in a macro's Condition column, you would have to leave the "If" off of your
expression. however, if you're trying to use this expression (without the If
and the outer set of parens) with an OpenForm action, it's not going to
work. your Count expression refers to a control on the form, but the form is
not open when the expression is evaluated.

is your form bound to a query? and are you trying to determine if the query
returns any records *before* you open the form? if so, then try the
following expression in the macro Condition column, as

DCount(1, "MyQuery") > 0

substitute the name of the query that the form is based on. for more info on
the difference between the Count() function and the DCount() function, see
those topics in Access Help.

hth
 
tina said:
... try the
following expression in the macro Condition column, as

DCount(1, "MyQuery") > 0

And if that doesn't work, try it like this...
DCount("*","MyQuery")>0
 
i tested both your expression and mine, in an A2K db running A2003, and both
worked. does the "1" expression not work in specific other versions, Steve,
or is there a disadvantage i need to learn about? thx, tina :)
 
Tina,

Sorry for butting in. I had never seen the type of expression you used
with the 1, I didn't test it but I am surprised that it works. If it
owrks, I don't know of any disadvantage :-)
 
never "butting in", Steve; i always want to learn whatever i can, especially
from an MVP! i picked up the DCount(1, ... trick here in the newsgroups,
some time ago. but i didn't learn anything about it, so i'm glad to know
that it doesn't present hidden problems (afayk, anyway). thx again :)
 
Well, even though I know of no problems with this approach, I would also
not expect it to have any advantages either, compared with using * or
the name of a field.
 
Back
Top