I have a number of objects in my database which I need to see recalculated on screen as soon as they have been (new record) entered or changed (amended existing record). I have the following code in the "On Exit" event:-
If Me.Dirty Then
On Error GoTo err:
Dim BM As Variant
BM = Me.Bookmark
Me.Recalc
Me.Bookmark = BM
err:
Me.Cost.SetFocus
End If
Changing an existing record, this works fine, and the focus moves happily to the named object ("Cost" in this case) in the active record. The Recalc works.
When I enter a NEW RECORD, however, the focus moves to the named object in the PREVIOUS RECORD.
I suspect that this is because at the time of exiting the object the record has not yet been saved in the Recordset.
I have tried using RecordsetClone to update the recordset on exiting the first field. This puts the bookmark in the right place but doesn't do the Recalc!
So what I need is something which makes the new Record into an existing record, closes it and then reopens REMEMBERING THE BOOKMARK. Since I only have this problem with new records I also need something which can differentiate between new and existing records.
I would have thought that nobody would want to change or input figures on a screen without seeing the revised totals immediately and then just passing on to the next object; that in fact the Bookmark would default to the active record, saved or not; but no such luck!
I hope I have explained myself clearly; does anyone have any ideas?
If Me.Dirty Then
On Error GoTo err:
Dim BM As Variant
BM = Me.Bookmark
Me.Recalc
Me.Bookmark = BM
err:
Me.Cost.SetFocus
End If
Changing an existing record, this works fine, and the focus moves happily to the named object ("Cost" in this case) in the active record. The Recalc works.
When I enter a NEW RECORD, however, the focus moves to the named object in the PREVIOUS RECORD.
I suspect that this is because at the time of exiting the object the record has not yet been saved in the Recordset.
I have tried using RecordsetClone to update the recordset on exiting the first field. This puts the bookmark in the right place but doesn't do the Recalc!
So what I need is something which makes the new Record into an existing record, closes it and then reopens REMEMBERING THE BOOKMARK. Since I only have this problem with new records I also need something which can differentiate between new and existing records.
I would have thought that nobody would want to change or input figures on a screen without seeing the revised totals immediately and then just passing on to the next object; that in fact the Bookmark would default to the active record, saved or not; but no such luck!
I hope I have explained myself clearly; does anyone have any ideas?