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 / Modules / DAO / VBA / February 2005

Tip: Looking for answers? Try searching our database.

Need macro to stop if table is empty

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brent Sweet - 18 Feb 2005 14:13 GMT
Hello,
 I have a query that makes a table of tickets not assigned to our
technicians.  If the table has tickets in it, I want the macro to launch a
program, which I think I can do.  The problem I have is if the table is empty
the program still trys to assign and logs that it did assign.  I need help.  
What I would like to do is have some code that checks to see if the table is
empty, if it is I want it to stop there, if has a count >1 then I would like
for it to launch a macro.  Anybody have any idea how I should code this?  
Thanks.
Wayne Morgan - 18 Feb 2005 14:29 GMT
Try the DCount function.

If DCount("*", "[MyTable]") > 0 Then
   'Run Program Here
End If

Signature

Wayne Morgan
MS Access MVP

> Hello,
>  I have a query that makes a table of tickets not assigned to our
[quoted text clipped - 9 lines]
> for it to launch a macro.  Anybody have any idea how I should code this?
> Thanks.
Nikos Yannacopoulos - 18 Feb 2005 14:31 GMT
Brent,

If you are doing the work through a macro, then insert a StopMacro
action at the very top, with condition:

DCount("*","TableName") >= 1

so the macro will abort if no record is found in the table.

HTH,
Nikos

> Hello,
>   I have a query that makes a table of tickets not assigned to our
[quoted text clipped - 5 lines]
> for it to launch a macro.  Anybody have any idea how I should code this?  
> Thanks.
Brent Sweet - 18 Feb 2005 14:49 GMT
This sounds exactly like what I need, however where do I put in this condition.

> Brent,
>
[quoted text clipped - 17 lines]
> > for it to launch a macro.  Anybody have any idea how I should code this?  
> > Thanks.
Steve Schapel - 18 Feb 2005 18:11 GMT
Brent,

In your macro design window, if you do not see a Condition column, then
select Conditions from the View menu.

If you are going to apply Nikos's isea, of using a StopMacro action, I
think the Condition would be...
 DCount("*","TableName")=0

Signature

Steve Schapel, Microsoft Access MVP

> This sounds exactly like what I need, however where do I put in this condition.
 
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.