Where Statement for Autoexec macro

K

Ken G

I need a Where statment to run in an Autoexec macro that will cause a form to
open only if there is data to fill it. In other words, the form will not pop
open if the data source is empty - I have two data items that get fill data
for the two forms if a certain criteria is met.

I don't write much these days for Access so I am looking to find an already
done wheel.

Thanks,

Ken
 
S

Steve Schapel

Ken,

I agree entirely with Karl. Just to make it slightly more explicit, use a
Condition like this for the OpenForm action in your macro:
DCount("*","YourQuery")>0
.... where YourQuery is the name of the query (or table) that is the form's
Record Source.

--
Steve Schapel, Microsoft Access MVP


KARL DEWEY said:
Why not use DCount with your criteria >0 for the condition?



__________ Information from ESET Smart Security, version of virus signature database 4222 (20090707) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
K

Ken G

I tried:

[DCount]>0 in the Where Condition

but the empty form still opens.

Am I missing something?

Ken
 
K

Ken G

OH, there is the missing part!

Thanks

Steve Schapel said:
Ken,

I agree entirely with Karl. Just to make it slightly more explicit, use a
Condition like this for the OpenForm action in your macro:
DCount("*","YourQuery")>0
.... where YourQuery is the name of the query (or table) that is the form's
Record Source.

--
Steve Schapel, Microsoft Access MVP






__________ Information from ESET Smart Security, version of virus signature database 4222 (20090707) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
S

Steve Schapel

Ken,

This is not the Where Condition argument. It is the macro Condition. If
you don't see a Conditions column in the macro design window, select
Condition from the View menu.

--
Steve Schapel, Microsoft Access MVP


Ken G said:
I tried:

[DCount]>0 in the Where Condition

but the empty form still opens.

Am I missing something?



__________ Information from ESET Smart Security, version of virus signature database 4222 (20090707) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
K

Ken G

I see. Now it works.

Thanks

Steve Schapel said:
Ken,

This is not the Where Condition argument. It is the macro Condition. If
you don't see a Conditions column in the macro design window, select
Condition from the View menu.

--
Steve Schapel, Microsoft Access MVP


Ken G said:
I tried:

[DCount]>0 in the Where Condition

but the empty form still opens.

Am I missing something?



__________ Information from ESET Smart Security, version of virus signature database 4222 (20090707) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
S

Steve Schapel

Excellent. Best wishes with the rest of the project, Ken.

--
Steve Schapel, Microsoft Access MVP


Ken G said:
I see. Now it works.

Thanks



__________ Information from ESET Smart Security, version of virus signature database 4222 (20090707) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 

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