Auto transfer value to next record

  • Thread starter Thread starter Balmora
  • Start date Start date
B

Balmora

Ok! this is somting defrant, i want to be able to transfer a value from one
record to the next with some vb. Here is what i have, in table1: ID
(AutoNumber) data1 (Currency) data2 (Currency) datatotal (Currency)

The hole idea is to transfer forward the value of the field datatotal to the
next record but not to datatotal but to data1.

i have found that if i use:

Private Sub datatotal_AfterUpdate()
With Me.datatotal
.DefaultValue = .Value
End With
End Sub

I can send forward the value to the next record in datatotal

i have also found that if i use:

Private Sub datatotal_AfterUpdate()
If Not IsNull(Me.datatotal) Then
Me.data1 = Me.datatotal
End If
End Sub

I can send the value of datatotal to data1 but only in the same record set.
My question would be now, how can i combine both together so it can send
forward the value of datatotal to data1 in the next record?
 
Private Sub datatotal_AfterUpdate()
If Not IsNull(Me.datatotal) Then
Me.data1.DefaultValue = Me.datatotal
End If
End Sub
 
Balmora said:
Ok! this is somting defrant, i want to be able to transfer a value from one
record to the next with some vb. Here is what i have, in table1: ID
(AutoNumber) data1 (Currency) data2 (Currency) datatotal (Currency)

The hole idea is to transfer forward the value of the field datatotal to the
next record but not to datatotal but to data1.
[snip some attempted code]


That kind of thing is a very bad idea in a database. It
would make sense in a spreadsheet, but saving calculated
values and having a value duplicated from one record to the
next would just cause all kinds of problems in a database.

Calculated values need to be recalculated every time you run
a query, form or report. Calculating a running total in a
report is very simple because you can use a text box's
RunningSum property.

For queries (and forms), you can use a subquery to calculate
a running total. How you would write the subquery depends
on the data in your table, especially the presence of one or
more fields that provide a unique sorting of the records.
 
Linq said:
Private Sub datatotal_AfterUpdate()
If Not IsNull(Me.datatotal) Then
Me.data1.DefaultValue = Me.datatotal
End If
End Sub

Thanks for your intrest, i tryed your solution and did not work :( i even
added .value to Me.datatotal so it looked like this Me.data1.DefaultValue =
Me.datatotal.value and it did not work to :( any more ideas?
 
Back
Top