Evaluating a field value

Merlin

New member
Local time
Today, 08:15
Joined
Jul 11, 2002
Messages
9
Trying to valuate a field value against a previous field value. If they are the same I want to increment a number count.

Field Value Exp:Seq count
211 1 No previous
212 1 Previous unequal
213 1 Previous unequal
213 2 Previous equal +1
213 3 Previous equal +1


Idea is that if previous value does not equal current value then assign one. If it does equal the previous value then increment the number. And continue to increment until no longer equal.

I don't see anywhere in Access that allows a comparison of current value to the previous value in a field

:confused:

The challenge is clear....anyone out there up to it!!

Thank you.

Merlin
 
All you have to do is store the last record 's value in a variable. Then you can compare that variable with the new record when it's entered and make the necessary adjustment before updating the new record.
 
Incremetning / counting dependent on relationship

FINALLY!!!

Below is the code that allowed me to look at an invoice number and compare to the previous number and then create a field entry based on that relationship.

Hoping it will help anyone else caught in the same predicament! Thanks so much to those that assisted.....much appreciated




Dim rsInvoices As Recordset
Dim intInvNo As String
Dim intDistCnt As Integer
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set db = CurrentDb
Set rsInvoices = db.OpenRecordset("qryInvoices", dbOpenDynaset)

intInvNo = 0
intDistCnt = 0

With rsInvoices
.MoveFirst
Do While Not .EOF
If !invoice = intInvNo Then
intDistCnt = intDistCnt + 1
Else
intDistCnt = 1
End If

.Edit
!dist_seq_nbr = intDistCnt
.Update

intInvNo = !invoice

.MoveNext
Loop
End With
Set rsInvoices = Nothing
Set db = Nothing
End Function
 

Users who are viewing this thread

Back
Top Bottom