So, I have a function that's meant to emulate += in Access to add a value to another value without having to repeat the first value. It's a simple function:
The function works fine except when I pass it a recordset field object. E.g.:
This doesn't throw an error, but it simply doesn't work.
If I step through the pe function, then varBaseAmt is indeed updated with the correct total. But it's not passed back to the calling function.
I would think that since varBaseAmt was ByRef variable of type Variant that it would work with a recordset field. Trying to understand why this doesn't work.
Thanks.
Code:
Public Function pe(ByRef varBaseAmt As Variant, varNewAmt As Variant)
varBaseAmt = Nz(varBaseAmt, 0) + Nz(varNewAmt, 0)
End Function
The function works fine except when I pass it a recordset field object. E.g.:
Code:
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("Table1", dbOpenDynaset)
rs.Edit
pe rs!Field1, 1
rs.Update
This doesn't throw an error, but it simply doesn't work.
If I step through the pe function, then varBaseAmt is indeed updated with the correct total. But it's not passed back to the calling function.
I would think that since varBaseAmt was ByRef variable of type Variant that it would work with a recordset field. Trying to understand why this doesn't work.
Thanks.
Last edited: