ClaraBarton
Registered User.
- Local time
- Today, 03:13
- Joined
- Oct 14, 2019
- Messages
- 651
Everything I've read says to close the calling form before opening the new form.
If I don't dim and set the strWhere and the OpenArgs before the form closes I lose them. I can do that or I can move the DoCmd.Close to after the DoCmd.OpenForm. What is the proper way and why?
Code:
Private Sub btnEdit_Click()
10 On Error GoTo btnEdit_Click_Error
Dim strWhere As String
20 strWhere = "[RecipeID] = " & Nz(Me.recipeid, 0)
30 DoCmd.Close acForm, Me.name
40 DoCmd.OpenForm "frmAddEdit", _
View:=acNormal, _
WhereCondition:=strWhere, _
OpenArgs:=Me.name
50 On Error GoTo 0
60 Exit Sub
btnEdit_Click_Error:
70 MsgBox "Error " & Err.Number & " (" & Err.description & ") " & _
" in procedure btnEdit_Click, line " & Erl & "."
End Sub