Adding Code

timothyl

Registered User.
Local time
Yesterday, 22:41
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
 
Just put your code between these two lines:
Exit_cmdDelete_Click:
...your code here...
Exit Sub
 
Duplicate Post (from here http://www.access-programmers.co.uk/forums/showthread.php?t=173299)

PLEASE - Do not post the same question more than once. If you post to the wrong category, click the triangle with the exclamation mark and report it to the mods/admins and they will move it for you.
 
Sorry, first time here, realized I posted in wrong place. Thanks for the heads up
 

Users who are viewing this thread

Back
Top Bottom