Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Macros / July 2005

Tip: Looking for answers? Try searching our database.

Expression Builder Problems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TF@Work - 11 Jul 2005 17:03 GMT
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!
tina - 11 Jul 2005 19:06 GMT
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

> 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
[quoted text clipped - 7 lines]
> and other various combinations but no luck! Any insight would be greatly
> appreciated!
Steve Schapel - 11 Jul 2005 20:21 GMT
> ... 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

Signature

Steve Schapel, Microsoft Access MVP

tina - 11 Jul 2005 21:43 GMT
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  :)

> > ... try the
> > following expression in the macro Condition column, as
[quoted text clipped - 3 lines]
> And if that doesn't work, try it like this...
>   DCount("*","MyQuery")>0
Steve Schapel - 11 Jul 2005 22:21 GMT
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 :-)

Signature

Steve Schapel, Microsoft Access MVP

> 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 - 12 Jul 2005 00:04 GMT
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  :)

> Tina,
>
[quoted text clipped - 5 lines]
> > worked. does the "1" expression not work in specific other versions, Steve,
> > or is there a disadvantage i need to learn about?  thx, tina  :)
Steve Schapel - 12 Jul 2005 00:23 GMT
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.

Signature

Steve Schapel, Microsoft Access MVP

> 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  :)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.