Adding new code after exsiting code

timothyl

Registered User.
Local time
Today, 17:39
Joined
Jun 4, 2009
Messages
92
Hello, I have a small form with a txtbox and a command button for deleting records from a table, it works well but I want to add a reset phrase so the txtbox will clear after the delete and refresh the form, the code behind the button is
Sub Command0_Click()

On Error GoTo Err_cmdDelete_Click

Dim SQL_Text As String

SQL_Text = "Delete * from Equipment WHERE DemoID = Forms!frmDelete!TxtDemoID"
DoCmd****nSQL (SQL_Text), acEdit

Exit_cmdDelete_Click:
Exit Sub

cmdDelete_Error:
Select Case Err.Number
Case 3059
MsgBox "You have canceled the delete operation.", vbOKOnly, "Delete Canceled"
Exit Sub
Case Else
MsgBox "Error number: " & Err.Number & " has occurred. " & Err.Description, vbOKOnly, "Error"
End Select

Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click


End Sub

works well, it's at the bottom of this I would like to add the reset and refresh code.

Dim intIndex As Integer
Me.TxtDemoID = ""
Me.Refresh

This last bit work behind a button all by itself.

Any help is appreciated
 
What's the question? You should be able to add the second bit to the first (right before Exit_cmdDelete_Click: ).
 
Last edited:
That's what I thought but it's just ignored
 
What exactly did you try?
 
Wait I was puting it in the wrong place I did as you suggested and it worked Thank you pbadly

Sub Command0_Click()

On Error GoTo Err_cmdDelete_Click

Dim SQL_Text As String

SQL_Text = "Delete * from Equipment WHERE DemoID = Forms!frmDelete!TxtDemoID"
DoCmd****nSQL (SQL_Text), acEdit
Dim intIndex As Integer
Me.TxtDemoID = ""
Me.Refresh
Exit_cmdDelete_Click:
Exit Sub

cmdDelete_Error:
Select Case Err.Number
Case 3059
MsgBox "You have canceled the delete operation.", vbOKOnly, "Delete Canceled"
Exit Sub
Case Else
MsgBox "Error number: " & Err.Number & " has occurred. " & Err.Description, vbOKOnly, "Error"
End Select

Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click


End Sub
 

Users who are viewing this thread

Back
Top Bottom