Hello Access-Programmers,
I have a simple date stamp that works great in a private sub within a form. (error handling removed for clarity)
I am rewriting it as Module function that is Called from various forms, to save space. The function receives the parameters varFormName and varControlName. I wish to write the results of the function back to a memo field on the form.
I am stumped at the get go by the need to refer to the Forms controls with a full reference instead of the Me command.
I think once I understand how to refer to the forms control's with their full reference, from within the Module's function, the rest will fall into place.
Thanks for any help.
I have a simple date stamp that works great in a private sub within a form. (error handling removed for clarity)
Code:
Private Sub btnDateStamp_Click()
' UserInit is global variable
Me!Notes.SetFocus
Me!Notes = Chr$(13) & Date & " - " & Time() & " - " & UserInit & _
" -" & vbCrLf & Me!Notes
Me!Notes.SelStart = (Len(Me!Notes) - (Len(Me!Notes) _
- Len(Date) - Len(Time) - Len(UserInit) - 9))
End Sub
I am rewriting it as Module function that is Called from various forms, to save space. The function receives the parameters varFormName and varControlName. I wish to write the results of the function back to a memo field on the form.
I am stumped at the get go by the need to refer to the Forms controls with a full reference instead of the Me command.
Code:
Function DateStamp(varFormName As String, varMemoName As String)
'varInitials, varFormName, varMemoName are global variables
Forms!varFormName.Controls!varMemoName.SetFocus ' [COLOR=red]Error here[/COLOR]
'Me!Notes = Chr$(13) & Date & " - " & Time() & " - " & varInitials & _
' " -" & vbCrLf & Me!Notes
'Me!Notes.SelStart = (Len(Me!Notes) - (Len(Me!Notes) _
' - Len(Date) - Len(Time) - Len(varInitials) - 9))
End Function
I think once I understand how to refer to the forms control's with their full reference, from within the Module's function, the rest will fall into place.
Thanks for any help.