unable to trap EOF & BOF I no it simple but I can not see where I am going wrong

I have written some buttons on my form to move through the records.  I am unable to get them to stop when they get the end of the file or Begining of the file the code Iam using is a follows

If Not Me.Recordset.EOF Then DoCmd.GoToRecord , , acNext

If have also tried

If Not Me.Recordset.EOF = true  Then DoCmd.GoToRecord , , acNext

I no it is something stupied any idears
lockaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JohnK813Commented:
Will this suit your needs?

While Not Me.Recordset.EOF
  DoCmd.GoToRecord , , acNext
Wend

You could also try the command

Me.RecordSet.MoveNext

instead of the DoCmd line.
0
GreymanMSCCommented:
You have a boundary condition error in your logic.
 
EOF is true only when you have gone PASSED the last record in the set, but not when you are just ON it.  Likewise with BOF and the first record.  That's why your code is never doing what you expect on the last and first records.
 
You'll need to first attempt to move, THEN to roll back if you've gone to an EOF or BOF.  Even better, test a move using a Recordset.Clone before before actually making it on the Recordset itself.
0
lockaAuthor Commented:
found this code to solve my problems it also allows me to disable buttons that are unaviable.

Private Sub previous_Click()
If Me.CurrentRecord = 1 Then
   Me.Next.Enabled = True
   Me.Next.SetFocus
   Me.previous.Enabled = False
Else
    DoCmd.GoToRecord , , acPrevious
   Me.previous.Enabled = True
End If
End Sub
Private Sub Next_Click()
If Me.CurrentRecord = Me.RecordsetClone.RecordCount Then
    Me.previous.Enabled = True
    Me.previous.SetFocus
    Me.Next.Enabled = False
Else
    DoCmd.GoToRecord , , acNext
    Me.Next.Enabled = True
End If
End Sub
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

JohnK813Commented:
If you've answered this yourself, feel free to ask for a refund here: http://www.experts-exchange.com/Community_Support/
0
lockaAuthor Commented:
I will when I get rounf to it.  Thanks for your help though I did try your example but all that happned was it scrolled quickly though your record set.
0
JohnK813Commented:
Ah, yes, I see I misread the question a bit.  It looks like your solution is the thing to do in your case (obviously).
0
PAQ_ManCommented:
PAQed with points refunded (50)

PAQ_Man
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.