klanc
klanc

Reputation: 241

VBA Access IF condition

I have a problem that my IF somehow doesn't validate good value of the field on index 0.

Here is the UDPATED code:

Private Sub Parametri()

Dim db As dao.Database
Dim rs As dao.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("ribe")


rs.MoveLast
rs.MoveFirst

For i = 0 To rs.RecordCount
    If rs.Fields(i).Value > 2 Then

        Debug.Print rs.Fields("Lokacija_GS")
        rs.MoveNext
    End If
Next



End Sub

And here is the result:

1
43.626145
43.626145
43.630122
43.632358
43.625833

This value of "1" on index 0 should be skipped... but it isnt?

here is the table:

enter image description here

So for example if some row is 0 or 1 or NULL I want to skip it...

Upvotes: 0

Views: 83

Answers (1)

PaulFrancis
PaulFrancis

Reputation: 5809

Here is the correct code,

Private Sub Parametri()
    Dim db As dao.Database
    Dim rs As dao.Recordset

    Set db = CurrentDb
    Set rs = db.OpenRecordset("ribe")

    rs.MoveLast
    rs.MoveFirst

    Do While Not rs.EOF
        If rs.Fields("Lokacija_GS").Value > 2 Then _
            Debug.Print rs.Fields("Lokacija_GS")
        rs.MoveNext
    Loop

    Set rs = Nothing
    Set db = Nothing
End Sub

Upvotes: 2

Related Questions