Sheila,
Your syntax as you have it will give you the *last [Claimant] * in your
query *not* the last amount for your current [Claimant],This may well be the
one in the code you are just adding if it the form has been update during
entry!!!
I'm afraid that if you want to insert a pervious payment for a supplier in
the current record you will have to do it in VB. You cannot do it in the
properties sheet because when you are adding a new record, until you enter
the supplier there is no supplier in your current record to search for
his/her last payment. In property sheet you will get nothing (null), wrong
value or an error, depending how you set it.
Furthest Dlast will only work if your query is sorted by date, my suggestion
is to use the DMax function on the YrPayDate, in which case you don't have
to worry about the sorting. Assuming that you selecting the claimant by a
Combo Box use the [event procedure] of the After Update *of the field*
Private Sub YourCombo_AfterUpdate()
Dim Last_ID as Long
Last_ID=Dmax("[yrPayDate]","Q_Add Remittance Info","[CaimantID]=" &
Me.ClaimatID _
& " AND [YrPayment_ID]<>" & Nz(Me.YrPayment_ID,0))
Me.yrAmount.DefaultValue=DLookup("[yrAmount]","Q_Add Remittance
Info","[YrRemittance_ID=" _
& Me.yrRemittance_ID)
End Sub
Regards/JK
[QUOTE="Sheila D"]
Thanks Barry - I can see the logic of this and have set the Supplier as a
combo box at the top of the form. I then have a query which uses the value
from that field as it's criteria and have set the Default Value for the
first
field (Claimant) I want to set as follows:
=DLast("[Claimant]","[Q_Add Remittance Info]")
where the Query uses the criteria from the Supplier field in the form
This does not seem to work - I've tried setting the After Update property
of
the Supplier field to open the Query (which does show the correct records)
and also not opening the query - what am I missing, any ideas.
Sheila
Barry Gilbert said:
Sheila,
You shouldn't need too much code, if any. You might look into using the
DLast function to get the previous record and use the expression in the
Default Value property for each control. To make sure DLast finds the
last
record, create a query that orders and filters the records and point
DLast to
this query.
Barry
[/QUOTE]