creating a delete record command button with access as the front e

M

mrsgwen

what is the code in Visual Basic for the Delete Record command? I am using
Access as the front end. I used the command button wizzard but the delete
record code that is attached to that command is not working for me. Can
anyone advise?
 
T

Tim Ferguson

what is the code in Visual Basic for the Delete Record command?


' command to delete the record currently looked at.
' if there are child records you'll need to delete those too
jetSQL = "DELETE FROM MyTable WHERE ID = """ & Me!txtID & """"

' carry it out. Remember to trap any possible error
CurrentDB().Execute jetSQL, dbFailOnError

' now do something meaningful with the user interface; either
' move to the next record, or the previous one, or just remove
' the form from sight altogether.
DoCmd.Close acForm, Me.Name


Hope that helps


Tim F
 
Top