maxmangion
AWF VIP
- Local time
- Today, 20:45
- Joined
- Feb 26, 2003
- Messages
- 2,805
I have some forms, which i have an Add Record on them. Now in order to avoid putting the code on each and every button, i am thinking of writing a public sub and then simply call this sub from each command button. I tried using the following code, but it is not working:
Eventually, i substituted the following line:
and it seems to work fine now. However, do you think that the above code is correct or shall i amend something ?
Thank You
Code:
Public Sub AddRecord (FocusField As String)
On Error Goto Err_AddRecord
DoCmd.GoToRecord , , acNew
FocusField.SetFocus
Exit_AddRecord:
Exit Sub
Err_AddRecord:
MsgBox Err.Description, vbExclamation + vbOkOnly, "Error #" & Err.Number & " - " & Err.Source
Resume Exit_AddRecord
End Sub
Eventually, i substituted the following line:
Code:
Public Sub AddRecord (FocusField As String)
with
Public Sub AddRecord (FocusField As Control)
and it seems to work fine now. However, do you think that the above code is correct or shall i amend something ?
Thank You