You have a couple of options. First, you don't have to use any If statment at all.
VB Code:
  1. Private Sub Command1_Click()
  2. On Error Goto ErrTrap
  3. 'code for click event
  4. Exit Sub
  5. ErrTrap:
  6. 'use eusty's example
  7. Open "c:\ErrorLog.txt" For Append As #1
  8. Print #1, Format(Now, "mm/dd/yyyy") & " " & Err.Number & " " & Err.Description
  9. Close #1
  10. End Sub
This will trap and log the error. Note, no code after the error will be executed.

If you want to trap for a specific error, as well as all other errors, then you can use the If statement
VB Code:
  1. Private Sub Command1_Click()
  2. On Error Goto ErrTrap
  3. 'code for click event
  4. Exit Sub
  5. ErrTrap:
  6. If Err.Number = 3021 Then
  7.    'do something for this specific error
  8. Else
  9.    'do something else regardless of what the error is
  10. End If
  11. End Sub
Again, no code will be executed after the line the error occurred on. If you want to trap and log the error, and continue code execution, then in your error trap, log the error, then add a Resume Next, which will continue executing the code after the line on which the error has occured.