[AccessD] vba to Delete mult records continous form

Darren Dick D.Dick at uws.edu.au
Tue May 10 21:27:40 CDT 2005


Hi Kath
Something I use is a 'delete flag'
It goes something like this.
Say we have a table called tblStudents
In that table is many fields but I usually put in a field with a data
type of number and call it ISSELECTED

Can be used for many things - in this case deleting
Have all the students show up in the continuous form and bind the
ISSELECTED field to a check box with 
a Heading Label called DELETE or something like it
The have the user "selects a block of records to delete."
Then have a button that says "Delete all records marked for deletion" or
something equally inane and have it
run SQL like...

DELETE tblStudents.*, tblStudents.IsSelected FROM tblStudents WHERE
(((tblStudents.IsSelected)=-1));

Once that has been done reset those with -1 in ISSELECTED back to Zero -

YOU MUST DO THIS EACH TIME YOU USE ISSELECTED SP that whatever you use
it for in the future only has the 'relevant'
Records selected.
Something like....
UPDATE tblStudents SET tblStudents.IsSelected= 0 WHERE
(((tblStudents.IsSelected)=-1));
Or
Just do the whole table
UPDATE tblStudents SET tblStudents.IsSelected= 0;

Hope this helps

See ya

Darren



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kath Pelletti
Sent: Wednesday, 11 May 2005 10:49 AM
To: AccessD at databaseadvisors.com
Subject: [AccessD] vba to Delete mult records continous form

Hi everyone - maybe I am just having a bad day but can someone tell me
the code I need in vba to do the same action as the [Records]  [Delete]
menu? ie. I have a continuous form, user selects a block of records to
delete. 

If I use DoCmd.RunCommand acCmdDeleteRecord then it only takes out the
first rec.

How can I get rid of them all? I could do it with a delete sql string if
I knew how to reference the selected records.

TIA
Kath

______________________________________________
Kath Pelletti
Software Design & Solutions Pty Ltd.
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list