Hi all,
I have a listbox which lists all the accounts, and I would like to handle error when user did not select any account in the list box but then click on "view/edit" button. The following is my code. However, I keep on having the blank account form open on the top of the error message. Any idea? thanks
Private Sub cmdEditAcct_Cli ck()
Dim Title As String
Dim Msg As String
On Error GoTo Err_cmdEditAcct _Click
DoCmd.RunMacro "mcrEditAcc t" 'open form
[Forms]![fdlgEditAccount]![txtUsername] = [Forms]![frmEdit]![txtUsername]
Exit_cmdEditAcc t_Click:
Exit Sub
Err_cmdEditAcct _Click:
Select Case Err
Case 2448 'No account selected
Title = "Select Account"
Msg = "You must first select an Account to make correction."
Msg = Msg & " Please click on an Account in the All Accounts listbox."
Beep
MsgBox Msg, vbExclamation, Title
Resume Exit_cmdEditAcc t_Click
Case Else
MsgBox Error$
Resume Exit_cmdEditAcc t_Click
End Select
End sub
I have a listbox which lists all the accounts, and I would like to handle error when user did not select any account in the list box but then click on "view/edit" button. The following is my code. However, I keep on having the blank account form open on the top of the error message. Any idea? thanks
Private Sub cmdEditAcct_Cli ck()
Dim Title As String
Dim Msg As String
On Error GoTo Err_cmdEditAcct _Click
DoCmd.RunMacro "mcrEditAcc t" 'open form
[Forms]![fdlgEditAccount]![txtUsername] = [Forms]![frmEdit]![txtUsername]
Exit_cmdEditAcc t_Click:
Exit Sub
Err_cmdEditAcct _Click:
Select Case Err
Case 2448 'No account selected
Title = "Select Account"
Msg = "You must first select an Account to make correction."
Msg = Msg & " Please click on an Account in the All Accounts listbox."
Beep
MsgBox Msg, vbExclamation, Title
Resume Exit_cmdEditAcc t_Click
Case Else
MsgBox Error$
Resume Exit_cmdEditAcc t_Click
End Select
End sub
Comment