delete subform record

J

Jim Franklin

Hi, can anyone tell me the best way to delete the current record in a
subform, using a command button on a mainform?

I know this should be easy, but...

Thanks,
Jim F.
 
W

Wayne Gillespie

Hi, can anyone tell me the best way to delete the current record in a
subform, using a command button on a mainform?

I know this should be easy, but...

Thanks,
Jim F.

I use SQL to dlete the record directly from the table and then requery the
subform -

Dim strSQL as String
Dim vMyID as Variant (change this to string. long etc to suit your data)

vMyID = Me.frmMySubForm.Form!MyIDField
strSQL = "DELETE * FROM tblMyTable WHERE ((MyIDField)=" & vMyID & ");"
CurrentDB.Execute strSQL, dbFailOnError
Me.frmMySubForm.Form.Requery


Wayne Gillespie
Gosford NSW Australia
 
Joined
Jul 22, 2007
Messages
1
Reaction score
0
Too long

The way of Wayne Gillespie is very complex.I have a best way to you :

[font=&quot]Private Sub DeleteSub_click()
Me.Sub1.SetFocus
With Me.Sub1
DoCmd.DoMenuItem acFormBar,acEditMenu,8,,acMenuVer70
DoCmd.DoMenuItem acFormBar,acEditMenu,6,,acMenuVer70
End With
End Sub

Sub1 is a name of SubForm
Good luck
[/font]
 

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