Checkbox to delete

raphael99

Registered User.
Local time
Today, 03:41
Joined
Apr 6, 2015
Messages
126
Hi
I have a form based on query. Each record has a checkbox.
I would like when activate checkbox to delete the specific record. from a button in the form.
Have not find anything around
 
Is this a multi-user database raphael? And if it is, is the form going to be used by multiple people?
 
Hi vbaInet
It is a single user database. Only one person have his own copy
 
Ok. What you need to do is commit any changes, then run a DELETE query/statement that will delete any records where the field bound to the checkbox is No or 0 or False (whichever one you choose).
 
I set up delete query "Querydieliminazione PIP" based on query "QueryPIPPerUnire" With all fields that are related to the form "FRMtblAnagraficatest".
In the criteria of checkbox "Seleziona" I wrote
Code:
[FRMtblAnagraficatest].[FRMTabellaJoinPIP_Sottomascheratest].[Seleziona]="-1"
But it says impossible to delete from table.
I upload a sample db if you want to get a viewView attachment work.accdb
 
You need to do three things:

1. Use FieldName = -1 and not what you have above.
2. Make sure the query is the same as the Record Source of the form
3. Save any changes before you run the query:
Code:
If Dirty Then Me.Dirty = False
 
1) I set FieldName (Seleziona) value -1
2) The query is the same as form's record source
3) set up a command button when clicked on it runs
Code:
If Dirty Then Me.Dirty = False
4) run " me.requiry" on form's after delete event

Results nothing happens. If checkbox is checked or not it does nothing.
I'm sure I'm mistaking something. But what?
 
Update. Maybe I should run delete query as record source of form. But in Access Delete Query does not appear as record source. How to overcome?
Update 2. I can't even run delete query : msgbox "impossible to delete from specific tables"

PS The delete query is base on 2 tables
 
Last edited:
Open the query in datasheet view.

Select a record by clicking on the record selector on the left. Then press the delete key on the keyboard.

If this works then you know that the query is correct. If not then you have a problem elsewhere.

Please advise.
 
Code:
If Dirty Then Me.Dirty = False

You could simplify this with.

Code:
Me.Dirty = False
 
Hi RainLover
The query can delete rows as you suggest.
But the delete query cannot run as datasheet. When I run it it says "could not delete from specified tables". As suggests Microsoft I set Unique record property on Yes, but also is not working
 
Let me see the db with the following setup.
1) I set FieldName (Seleziona) value -1
2) The query is the same as form's record source
3) set up a command button when clicked on it runs
Code:
If Dirty Then Me.Dirty = False
4) run " me.requiry" on form's after delete event
... only include the relevant form, tables and queries.
 
Ah, so you want to delete the current record? So what is the point of the checkbox then?
 
No I would like to choose what I delete. Can be current record or past time record
 
In that case the "Delete" button should not be on every record.

And you delete from one table, not from multiple tables.
 
Ok now the command button is one, single one on the header.
I know that "DescrizionePIP" is on "TabellaPIP" meanwhile "DataPIP" is on "Tabella JoinPIP"
 
Which table do you want to delete the records from?
 
I would like to delete the recorded row which it is performance (DescrizionePIP) and dates (DataPIP).
I would like to select the row and delete it
 

Users who are viewing this thread

Back
Top Bottom