Albert Kallal's Multi-Select to delete selected records?

M

Marshall Barton

biganthony said:
I have used Albert Kallal's multi-select (
http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html) example to
select records on a continuous form and have them displayed on a report.

Is it possible to use similar logic to Albert's multi-select example to
delete selected records from a continuous form?


WARNING: Form's do not contain records so you can not
"delete" records from a form. You can only delete records
in a table, which is rarely a good idea because once
deleted, they are gone forever.

If you are just using the word "delete" when you really mean
that you don't want the form to display those records, then
you can use code similar to what you already have for the
report to modify the form's record source query.
 
A

Albert D. Kallal

sure, just take the "list" of id that the code returns and use that for a
delete statement....


dim strSql as string

strSql = "delete * from tbableName where id in (" & MySelected & ")"
docmd.runsql strSql

Do use caution the above as we're talking about code that deletes records, I
suggest you thoroughly test this on a copy of the database before you put
this code and production, as deletion code can be a very dangerous thing to
implement in any application

The example code provided shows how to open a report, or launch another form
that shows a selected list. All the code examples simply used them I
selected list of IDs it gets returned, and you can certainly use that same
list as above and code to delete records.
 
B

biganthony via AccessMonster.com

Thanks Albert.

sure, just take the "list" of id that the code returns and use that for a
delete statement....

dim strSql as string

strSql = "delete * from tbableName where id in (" & MySelected & ")"
docmd.runsql strSql

Do use caution the above as we're talking about code that deletes records, I
suggest you thoroughly test this on a copy of the database before you put
this code and production, as deletion code can be a very dangerous thing to
implement in any application

The example code provided shows how to open a report, or launch another form
that shows a selected list. All the code examples simply used them I
selected list of IDs it gets returned, and you can certainly use that same
list as above and code to delete records.
 

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