J
Jack Leach
Hello, thanks in advance.
I'm making an attempt to globalize a function, and looking for the best
method, if anyone has any thoughts.
My intent is to pass a field of the Form's recordset (rather than a control)
to a public function for update.
fldCrDate, fldCrBy, fldModDate, fldModBy... these are what I am trying to
pass to function SetTimeStamps(DateField, UserField)
I've done this enough times with Controls, but I thought it would be a
little cleaner to not put these controls on the form as hidden just for this
purpose.
If I declare the arguments as Field, I get a Type Mismatch. I switched to
Variant and the code didn't fail at runtime, but nothing was updated.
'=======
Public Function SetTimeStamps( _
ByRef DateField As Variant, _
ByRef UserField As Variant _
) As Boolean
DateField = Now()
If Len(Nz(gUSER, "")) <> 0 Then
UserField = gUSER
End If
End Function
'=======
and in the form's BeforeUpdate:
'=======
If Me.NewRec Then
SetTimeStamps Me.fldCrDate, Me.fldCrBy
End If
SetTimeStamps Me.fldModDate, Me.fldModBy
'=======
Should I instead try to pass the form's Recordset to the function? Or am I
stuck using hidden controls.
--
Jack Leach
www.tristatemachine.com
"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
I'm making an attempt to globalize a function, and looking for the best
method, if anyone has any thoughts.
My intent is to pass a field of the Form's recordset (rather than a control)
to a public function for update.
fldCrDate, fldCrBy, fldModDate, fldModBy... these are what I am trying to
pass to function SetTimeStamps(DateField, UserField)
I've done this enough times with Controls, but I thought it would be a
little cleaner to not put these controls on the form as hidden just for this
purpose.
If I declare the arguments as Field, I get a Type Mismatch. I switched to
Variant and the code didn't fail at runtime, but nothing was updated.
'=======
Public Function SetTimeStamps( _
ByRef DateField As Variant, _
ByRef UserField As Variant _
) As Boolean
DateField = Now()
If Len(Nz(gUSER, "")) <> 0 Then
UserField = gUSER
End If
End Function
'=======
and in the form's BeforeUpdate:
'=======
If Me.NewRec Then
SetTimeStamps Me.fldCrDate, Me.fldCrBy
End If
SetTimeStamps Me.fldModDate, Me.fldModBy
'=======
Should I instead try to pass the form's Recordset to the function? Or am I
stuck using hidden controls.
--
Jack Leach
www.tristatemachine.com
"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)