Phil wrote:
Newbie to Access so am having a BIT of difficulty.
I am trying to get a field value in a new record to equal the value of the
same field of a previous one.
For instance,
Field1 + Field2 = Field3
In the next record i want Field3 to have the default value of the previous
Field3.
Hope you can understand.
Thanks
Here is a function tha may work. I don't know if you store the values
to Field3.
Private Function Field3Default() As Long
'not sure is your values are long, currency, your choice
Dim rst As REcordset
set rst = Me.Recordsetclone
If rst.RecordCount > 0
rst.moveLast
Field3Default = rst!Field1 + rst!Field2
Endif
rst.close
set rst = nothing
End Function
You can now put this code into the OnCurrent event. Ex:
If Me.NewRecord Then
Me.Field3 = Field3Default()
Endif
I really don't see why you don't make Field1/2 have the default values
of the prior record and make Field3 a calc'd field since it is the
addition of the 2 that make up the result. I suppose you have a reason.