delete records from sub form

G

Guest

I'm trying to find out how to delete records from a sub form using a check
box feature.

It's a rather large database so as the user goes through editing there will
be records he will want to select for deletion. It may be one record or it
could be 10 (ormore). I have a check box field for this purpose.

If there's a check mark in the box on that record then it's to be deleted in
other words.

Then he'll click a command button and delete the records selected.

The code for the command button (named cmdremove) is as follows:

If thesub.Form!txttrash = -1 Then


On Error GoTo Err_cmdremove_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_cmdremove_Click:
Exit Sub

Err_cmdremove_Click:
MsgBox Err.Description
Resume Exit_cmdremove_Click

End If

Requery

End Sub

===========================================

Notes: "thesub" is the name of the sub form
"txttrash" is the name of the check box on the sub form

Absolutely nothing happens when I click my command button. No error message
and it doesn't delete the record either.

Can anyone provide guidance?
 
S

Steph

Do this instead:

Dim SQL
SQL = "DELETE FROM Table WHERE txtTrash = 1"
Docmd.RunSQL SQL
Me.Requery

Hope this helps.

Steph
 
G

Guest

Steph,

I'm getting a Run time error message.

It says:

Run-time error '3131':
Syntax error in FROM clause
 

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