Where Statement for Autoexec macro

  • Thread starter Thread starter Ken G
  • Start date Start date
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
 
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
 
I tried:

[DCount]>0 in the Where Condition

but the empty form still opens.

Am I missing something?

Ken
 
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
 
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
 
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
 
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
 
Back
Top