Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with this code.. DELETE statement

Status
Not open for further replies.

DJKAOS

Technical User
Jun 30, 2000
101
0
0
US
Hi,

I'm having trouble getting this delete statment to work.
here is my function, when you press the button it is supposed to delete the currently selected record.

Private Sub DeleteRecordButton_Click()
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
dbs.Execute "DELETE * FROM BREAKS WHERE MainID = [Forms]![BreaksForm]![MainID]"
End Sub

Problem is I get a Run Time error that says "to few parameters. expected 1"

I can't figure it out... if I Just change it to hard code a certain MainID then it works.

Private Sub DeleteRecordButton_Click()
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
dbs.Execute "DELETE * FROM BREAKS WHERE MainID = 543
End Sub
this works fine..and it deletes the record off the BREAKS table with MainID = 543.

Any help would be great..thanks.
 
Nevermind, I'm a bozo....

I fixed it..

Private Sub DeleteRecordButton_Click()
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
dbs.Execute "DELETE * FROM BREAKS WHERE MainID = " & Me.MainID
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top