Record Count Condition

D

Derek Wittman

Good morning
In my macro, I have actions to open a table, selectallrecords, and deleterecord. The problem I am having is that, if my table is already empty, I get an action failed message that I cannot delete records that do not exist

I think I need to build a condition that will cause this step to be skipped if the table is empty, but I don't see functions to make that happen. Can someone help? Thank you
Derek
 
P

Petrucci2000

Derek wrote:

--------------------
| Thread-Topic: Record Count Condition
| thread-index: AcPasrz4hGJZv6pJQRWNS+Nczz8QBg==
| X-Tomcat-NG: microsoft.public.access.macros
| From: "=?Utf-8?B?RGVyZWsgV2l0dG1hbg==?="
<[email protected]>
| Subject: Record Count Condition
| Date: Wed, 14 Jan 2004 07:26:10 -0800
| Lines: 5
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.access.macros
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
| Path: cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl
| Xref: cpmsftngxa07.phx.gbl microsoft.public.access.macros:29486
| X-Tomcat-NG: microsoft.public.access.macros
|
| Good morning,
In my macro, I have actions to open a table, selectallrecords, and
deleterecord. The problem I am having is that, if my table is already
empty, I get an action failed message that I cannot delete records that do
not exist.

I think I need to build a condition that will cause this step to be skipped
if the table is empty, but I don't see functions to make that happen. Can
someone help? Thank you!
Derek
|


Try this for your condition
DCount("[id]","[table1]")=0

Note: [id] is a primary key field in the table.


I hope this helps! If you have additional questions on this topic, please
respond back to this posting.


Regards,

Eric Butts
Microsoft Access Support

"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp> and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to install
the patch. Running the SCAN program from the Windows Update site will help
to insure you are current with all security patches, not just MS03-026."
 
N

Nikos Yannacopoulos

just before the line of code to delete:
On Error Resume Next
right after the line of code to delete:
On Error Goto 0 (or wherever the last error handler points to).

This way the deleting action will be skipped if no records > error.
HTH,
Nikos

Derek Wittman said:
Good morning,
In my macro, I have actions to open a table, selectallrecords, and
deleterecord. The problem I am having is that, if my table is already
empty, I get an action failed message that I cannot delete records that do
not exist.
I think I need to build a condition that will cause this step to be
skipped if the table is empty, but I don't see functions to make that
happen. Can someone help? Thank you!
 
D

Derek Wittman

Error handling? Isn't it easier to remove the errors? I've never thought of error handling...

Seems like there's got to be yet another FAQ out there for me to read

Dere

----- Nikos Yannacopoulos wrote: ----

just before the line of code to delete
On Error Resume Nex
right after the line of code to delete
On Error Goto 0 (or wherever the last error handler points to)

This way the deleting action will be skipped if no records > error
HTH
Niko

Derek Wittman said:
Good morning
In my macro, I have actions to open a table, selectallrecords, an
deleterecord. The problem I am having is that, if my table is alread
empty, I get an action failed message that I cannot delete records that d
not existskipped if the table is empty, but I don't see functions to make tha
happen. Can someone help? Thank you
 
D

Derek Wittman

Thanks! I don't have a Primary Key for this table. Of course, one of my fields is an Autonumber. I could probably make that a Key

Dere

----- \"Petrucci2000\" wrote: ----

Derek wrote

-------------------
| Thread-Topic: Record Count Conditio
| thread-index: AcPasrz4hGJZv6pJQRWNS+Nczz8QBg=
| X-Tomcat-NG: microsoft.public.access.macro
| From: "=?Utf-8?B?RGVyZWsgV2l0dG1hbg==?="
<[email protected]
| Subject: Record Count Conditio
| Date: Wed, 14 Jan 2004 07:26:10 -080
| Lines:
| Message-ID: <[email protected]
| MIME-Version: 1.
| Content-Type: text/plain
| charset="Utf-8
| Content-Transfer-Encoding: 7bi
| X-Newsreader: Microsoft CDO for Windows 200
| Content-Class: urn:content-classes:messag
| Importance: norma
| Priority: norma
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.
| Newsgroups: microsoft.public.access.macro
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.18
| Path: cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gb
| Xref: cpmsftngxa07.phx.gbl microsoft.public.access.macros:2948
| X-Tomcat-NG: microsoft.public.access.macro
|
| Good morning
In my macro, I have actions to open a table, selectallrecords, and
deleterecord. The problem I am having is that, if my table is already
empty, I get an action failed message that I cannot delete records that do
not exist

I think I need to build a condition that will cause this step to be skipped
if the table is empty, but I don't see functions to make that happen. Can
someone help? Thank you
Dere
|


Try this for your conditio
DCount("[id]","[table1]")=

Note: [id] is a primary key field in the table


I hope this helps! If you have additional questions on this topic, please
respond back to this posting


Regards

Eric Butt
Microsoft Access Suppor

"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp> and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to install
the patch. Running the SCAN program from the Windows Update site will help
to insure you are current with all security patches, not just MS03-026.
 
D

Derek Wittman

Okay, the condition is working. But later on in my macro, I have Close (form) and Quit. Neither of these are working now

Any ideas

Dere

----- \"Petrucci2000\" wrote: ----

Derek wrote

-------------------
| Thread-Topic: Record Count Conditio
| thread-index: AcPasrz4hGJZv6pJQRWNS+Nczz8QBg=
| X-Tomcat-NG: microsoft.public.access.macro
| From: "=?Utf-8?B?RGVyZWsgV2l0dG1hbg==?="
<[email protected]
| Subject: Record Count Conditio
| Date: Wed, 14 Jan 2004 07:26:10 -080
| Lines:
| Message-ID: <[email protected]
| MIME-Version: 1.
| Content-Type: text/plain
| charset="Utf-8
| Content-Transfer-Encoding: 7bi
| X-Newsreader: Microsoft CDO for Windows 200
| Content-Class: urn:content-classes:messag
| Importance: norma
| Priority: norma
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.
| Newsgroups: microsoft.public.access.macro
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.18
| Path: cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gb
| Xref: cpmsftngxa07.phx.gbl microsoft.public.access.macros:2948
| X-Tomcat-NG: microsoft.public.access.macro
|
| Good morning
In my macro, I have actions to open a table, selectallrecords, and
deleterecord. The problem I am having is that, if my table is already
empty, I get an action failed message that I cannot delete records that do
not exist

I think I need to build a condition that will cause this step to be skipped
if the table is empty, but I don't see functions to make that happen. Can
someone help? Thank you
Dere
|


Try this for your conditio
DCount("[id]","[table1]")=

Note: [id] is a primary key field in the table


I hope this helps! If you have additional questions on this topic, please
respond back to this posting


Regards

Eric Butt
Microsoft Access Suppor

"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp> and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to install
the patch. Running the SCAN program from the Windows Update site will help
to insure you are current with all security patches, not just MS03-026.
 
D

Derek Wittman

I'm an idiot. I wanted to SKIP the steps if the table was empty. So, I needed to change the = to a > in my condition

Thanks
Dere

----- \"Petrucci2000\" wrote: ----

Derek wrote

-------------------
| Thread-Topic: Record Count Conditio
| thread-index: AcPasrz4hGJZv6pJQRWNS+Nczz8QBg=
| X-Tomcat-NG: microsoft.public.access.macro
| From: "=?Utf-8?B?RGVyZWsgV2l0dG1hbg==?="
<[email protected]
| Subject: Record Count Conditio
| Date: Wed, 14 Jan 2004 07:26:10 -080
| Lines:
| Message-ID: <[email protected]
| MIME-Version: 1.
| Content-Type: text/plain
| charset="Utf-8
| Content-Transfer-Encoding: 7bi
| X-Newsreader: Microsoft CDO for Windows 200
| Content-Class: urn:content-classes:messag
| Importance: norma
| Priority: norma
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.
| Newsgroups: microsoft.public.access.macro
| NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.18
| Path: cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gb
| Xref: cpmsftngxa07.phx.gbl microsoft.public.access.macros:2948
| X-Tomcat-NG: microsoft.public.access.macro
|
| Good morning
In my macro, I have actions to open a table, selectallrecords, and
deleterecord. The problem I am having is that, if my table is already
empty, I get an action failed message that I cannot delete records that do
not exist

I think I need to build a condition that will cause this step to be skipped
if the table is empty, but I don't see functions to make that happen. Can
someone help? Thank you
Dere
|


Try this for your conditio
DCount("[id]","[table1]")=

Note: [id] is a primary key field in the table


I hope this helps! If you have additional questions on this topic, please
respond back to this posting


Regards

Eric Butt
Microsoft Access Suppor

"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp> and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to install
the patch. Running the SCAN program from the Windows Update site will help
to insure you are current with all security patches, not just MS03-026.
 
S

Steve Schapel

Derek,

Whereas the line of attack being followed elsethread will help you
achieve what you are trying to do, there is an easier way :) Just
make a Delete Query to delete all records from your table, and then
use an OpenQuery action in your macro to run the Delete. You might
want to put a SetWarnings,No action before the OpenQuery action to
suppress the display of the action query confirmation messages. There
will be no problem with this if the table is empty, so therefore no
need for macro conditions etc.

- Steve Schapel, Microsoft Access MVP
 

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