Gasman
Enthusiastic Amateur
- Local time
- Today, 12:06
- Joined
- Sep 21, 2011
- Messages
- 16,728
Hi,
Having some strange behaviour (for me at least) in a form.
I am aware that one should not store balance in a table, but was doing so so as to be able to report on it easily.
For this I used
to show the Balance (this is from the table).
There was no Me.Refresh at the time.
So I added a control txtBalance whose control source is
and then added the Me.Refresh
All works if I amend a record, however when adding a new record, it appears that the record pointer moves to the first record with that ID.?
I did have a Required = Yes for a field Reference, which is the next control after the Amount control, and that would complain that a Reference was required, so it appears the record movement was triggering this, and so I removed it. Now I am getting this anomaly.
I did not expect a DSUM to alter the record pointer, so I must be doing something a little stupid?
The form (just in case) is a basic emulated split form, with a Continuous Form as a subform on a main form with the same recordsource.
Any ideas as to what I have done wrong please.?
I realise not a lot to go on, but the DB holds confidential data, which I would have to clean if requested to upload.
TIA
Having some strange behaviour (for me at least) in a form.
I am aware that one should not store balance in a table, but was doing so so as to be able to report on it easily.
For this I used
Code:
Private Sub Amount_LostFocus()
If Me.TranType = "Payment" And Me.Amount > 0 Then
Me.Amount = Me.Amount * -1
End If
'Me.Balance = Nz(DSum("[Amount]", "Emails", "[CMS]=" & Me.CMS & " AND [TransactionDate] < " & Me.TransactionDate), 0)
Me.Balance = Nz(DSum("[Amount]", "qryEmails", "[CMS]=" & Me.CMS & " AND [ID] < " & Me.ID), 0)
If Me.NewRecord Or Me.Dirty Then
Me.Balance = Me.Balance + Me.Amount
End If
Me.Refresh
End Sub
There was no Me.Refresh at the time.
So I added a control txtBalance whose control source is
Code:
=DSum("Amount","Emails","CMS = " & [CMS] & " AND ID <= " & [ID])
All works if I amend a record, however when adding a new record, it appears that the record pointer moves to the first record with that ID.?
I did have a Required = Yes for a field Reference, which is the next control after the Amount control, and that would complain that a Reference was required, so it appears the record movement was triggering this, and so I removed it. Now I am getting this anomaly.
I did not expect a DSUM to alter the record pointer, so I must be doing something a little stupid?
The form (just in case) is a basic emulated split form, with a Continuous Form as a subform on a main form with the same recordsource.
Any ideas as to what I have done wrong please.?
I realise not a lot to go on, but the DB holds confidential data, which I would have to clean if requested to upload.
TIA