how do I delete a record

AMH

New member
Local time
Today, 13:16
Joined
Jun 19, 2001
Messages
9
Help Please !!!

I am trying to delete a record based on the invoice number selected from a
combo box. The code below finds the correct record but only deletes the
invoice number field rather then the whole record

hope someone can help

thanks in advance....


strinvnum = Me.cboinvnumber
Set rst2 = New ADODB.Recordset
rst2.Open "inputalloc", cnn, adOpenKeyset, adLockOptimistic,
adCmdTableDirect
rst2.Find "[InvoiceNumber]='" & strinvnum & "'", 0, adSearchForward
rst2.Delete
rst2.Update
rst2.Close
'
 
The easiest way I know to do a Delete from code is...

DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * FROM tblTableName WHERE InvoiceNumber = '" & me.cboInvNumber & "';"
DoCmd.SetWarnings True

Notes; Ensure that the value that you pass from the Combo box is unique, or multiple records will be deleted.
use the Single Quotes enclosed within the Double Quotes when you want to pass a String value that is being held in a control. If the value is a number, omit the Singles. If the value is a date, use #.
HTH
Chris
 
thanks for the help chris this seems to work well
 

Users who are viewing this thread

Back
Top Bottom