0

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...

4
  • Can you show us a bit more code please? Without that this piece make very minimal sense. Commented Aug 4, 2014 at 11:40
  • If you could check now :) Commented Aug 4, 2014 at 11:49
  • Just curious, why do a rs.MoveLast rs.MoveFirst is it some kind of access trick? Commented Aug 4, 2014 at 13:42
  • I don't really know. Very new to VBA and I saw this kind of structure in most of the examples :D , was wondering the same Commented Aug 4, 2014 at 14:44

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

2 Comments

You're welcome. Feel free to mark this as answer if it has solved your problem. Good luck.
Is it possible that I ask you a few more questions somehow ( skype or mail ) because I really am stuck on something or just need some guidelines and saw that you have some history in Access?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.