updating next record

KRRC

Registered User.
Local time
Today, 12:24
Joined
Nov 22, 2004
Messages
12
I'm working with a form (based on a table) that has one numeric field (CTarA) that is dependent on a different numeric field (TarA) of the previous record. When using the AfterUpdate method on field TarA, on an old record, is there a simple way of updating field CtarA of the next record?
I'm at beginners level and I have looked up this subject on Help, but with little success.
Thanks for any help you can spare

Kati
 
are they on the same table or two different tables?

I know you said a form is based on a table but does the form has a subform?
 
They're in the same table, and there is a single form...

Thank you for replying,
Kati
 
so if this is how your table looks like


RECID ---------------- TarA----------------------CTarA

1-------------------------A

2-------------------------B -------------------------A

3-------------------------C-------------------------B


the, A, B, C being the values






Private Sub TarA_AfterUpdate()
Dim TaraValue As String
TaraValue = Me.TarA

Recordset.AddNew
Me.CTarA.Value = TaraValue

End Sub
 
Last edited:
Thanks.
I have one question, if I go back and correct TarA to D where RECID = 1, will CTarA become equal to D where RECID = 2, or does it only work for new records?
 
Private Sub TarA_AfterUpdate()



Dim TaraValue As String, ThisRecordId As Integer, NextRecordID As Integer

TaraValue = Me.TarA
ThisRecordId = Me.RECID
Me.Form.Refresh
Recordset.MoveNext
NextRecordID = Me.RECID
Me.Form.Refresh
Recordset.MovePrevious

'MsgBox "this, Next" & ThisRecordId & NextRecordID

If ThisRecordId = NextRecordID Then
Recordset.AddNew
Else
Recordset.MoveNext
End If

Me.CTarA = TaraValue
Me.Form.Refresh

End Sub
 

Users who are viewing this thread

Back
Top Bottom