View Single Post
  #5  
Old April 7th, 2005, 12:17 PM
Arvin Meyer
external usenet poster
 
Posts: n/a
Default

Without a unique identifier for that record, you cannot delete just that
record using code. Is your unique id a text field? (your use of quotes
suggest that). Are you sure you are using the Primary Key for that record in
that table? (Your post suggests you are using the foreign key).
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

"Sam Kuo" .(donotspam) wrote in message
...
Arvin, sorry I didn't read your line clear enough. The lines below are

what I
really tried. I've however changed cboID to just ID because the records in
the subform are not filtered by combo box cboID.
The code would now delete ALL records with the same ID. But can I really
just delete any one record at a time? (because both textbox controls and

the
button are in the subform's Detail section, and the subform is in

continuous
form view, so for every record there's a delete button to be used to

delete
that particular record)

Private Sub cmdWhatever_Click()
CurrentDb.Execute "Delete * From tblMyTable Where ID ='" & Me.ID & "'"
Me.Requery
End Sub

Regards,
Sam


"Arvin Meyer" wrote:

Set the code for your command button like this:

Private Sub cmdWhatever_Click()
CurrentDb.Execute "Delete * From tblMyTable Where ID =" & Me.cboID
Me.Requery
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

"Sam Kuo" .(donotspam) wrote in message
...
Hi all,

I have created a button in a subform (with continuous form as the

default
view).
I'd like to be able to click the button and delete the record. How may

I
do
that?

Regards,
Sam