•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS Access and FileMaker Pro section within the Web Development category of DaniWeb, a massive community of 391,552 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,594 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS Access and FileMaker Pro advertiser:
Views: 1324 | Replies: 1
![]() |
•
•
Join Date: Aug 2006
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Good day,
Iam traying to get result of my record as below
If next record is biger than previous show "1"
If next record is same previous show "1"
If next record is smallest show "0"
if next record is same previous show "0"
Example
the code gave me correct result for some filed and other incorrect !
Could you please check the code and correct it for me.
I have attached the DB for any correction
Note: the command bottons on Form1 of Forms Object.
Iam very appreciated for assistant .
..
the code below and need updating.
Private Sub cmdUpdate_Click()
Dim cnn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim SQL As String
Dim Code As String
Dim Price As Long
'Dim Res As String
Dim Res As Variant
'Dim PrevRes As String
Dim PrevRes As Variant
Set cnn = CurrentProject.Connection
SQL = "Select [code],[Price],[Res] from [tt]" & _
" order by [code],[ID]"
rst.Open SQL, cnn, adOpenKeyset, adLockOptimistic
Do While Not rst.EOF
Code = rst![code]
Price = rst![Price]
'PrevRes = ""
PrevRes = Null
rst.MoveNext
Do While rst![code] = Code
'Res = IIf(rst![Price] > [Price], "1", IIf(rst![Price] < [Price], "0", IIf(rst![Price] = [Price], PrevRes, Null)))
Res = IIf(rst![Price] > [Price], "1", IIf(rst![Price] < [Price], "0", PrevRes))
rst![Res] = Res
PrevRes = Res
Price = rst![Price]
rst.MoveNext
If rst.EOF Then
Exit Do
End If
Loop
Loop
Set cnn = Nothing
Set rst = Nothing
MsgBox "Res field updated."
End Sub
Iam traying to get result of my record as below
If next record is biger than previous show "1"
If next record is same previous show "1"
If next record is smallest show "0"
if next record is same previous show "0"
Example
id Time Code Price Res 1 10:00:00 AM 1010 905 0 464 10:00:34 AM 1010 906 1 626 10:00:56 AM 1010 906 1 1523 10:02:16 AM 1010 904 0 1568 10:02:21 AM 1010 904 0 1569 10:02:21 AM 1010 905 1
Could you please check the code and correct it for me.
I have attached the DB for any correction
Note: the command bottons on Form1 of Forms Object.
Iam very appreciated for assistant .

..
the code below and need updating.
Private Sub cmdUpdate_Click()
Dim cnn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim SQL As String
Dim Code As String
Dim Price As Long
'Dim Res As String
Dim Res As Variant
'Dim PrevRes As String
Dim PrevRes As Variant
Set cnn = CurrentProject.Connection
SQL = "Select [code],[Price],[Res] from [tt]" & _
" order by [code],[ID]"
rst.Open SQL, cnn, adOpenKeyset, adLockOptimistic
Do While Not rst.EOF
Code = rst![code]
Price = rst![Price]
'PrevRes = ""
PrevRes = Null
rst.MoveNext
Do While rst![code] = Code
'Res = IIf(rst![Price] > [Price], "1", IIf(rst![Price] < [Price], "0", IIf(rst![Price] = [Price], PrevRes, Null)))
Res = IIf(rst![Price] > [Price], "1", IIf(rst![Price] < [Price], "0", PrevRes))
rst![Res] = Res
PrevRes = Res
Price = rst![Price]
rst.MoveNext
If rst.EOF Then
Exit Do
End If
Loop
Loop
Set cnn = Nothing
Set rst = Nothing
MsgBox "Res field updated."
End Sub
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MS Access and FileMaker Pro Marketplace
•
•
•
•
access activation api apple blogger blogging blogs code combo computing core dani daniweb data debugging development dreamweaver dropdownlist gdata google gpl html innovation ip key linux mac microshaft microsoft module ms net news openbsd pro processor product programming reuse rss serial source tags vista web wysiwyg xml
- Code 19 Registry Error (Windows NT / 2000 / XP / 2003)
- Why won't this code work? (VB.NET)
- Need help with DirectX code (C)
- Tutorials & Code Submissions - Questions? (DaniWeb Community Feedback)
- Some Basic Code Hopefully (Help Needed) (HTML and CSS)
Other Threads in the MS Access and FileMaker Pro Forum
- Previous Thread: Search Code Question
- Next Thread: Database access with Java platform


Linear Mode