Solved

BOF and EOF problems

Posted on 2006-11-30
7
351 Views
Last Modified: 2012-05-05
My research has failed, so here goes!  

Why does this stop movement to the previous form when I am currently not on the first record?  I am right now on record 7, and when I click on Previous button, it exits the sub.  If I put Not  before the rst.BOF, then it moves until I get to the first one, then another click gives an error message.  

What's wrong?  
Susan


Private Sub ToPrevious_Click()

    On Error GoTo Err_ToPrevious_Click

      blnEditsOK = False
If SaveMyRecord() = True Then
End If

Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("AQ00SubjectEligEnroll")
Forms![F00-All2].SetFocus

If rst.BOF Then
Exit Sub

        DoCmd.GoToRecord , , acPrevious
End If

Exit_ToPrevious_Click:
    Exit Sub

Err_ToPrevious_Click:
    MsgBox "This is the first record.", vbOKOnly, "First Record"
    Resume Exit_ToPrevious_Click
   
End Sub
0
Comment
Question by:skennedy10
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:dan_vella
ID: 18048433
Looks like you might be missing the else:

If rst.BOF Then
Exit Sub

ELSE
        DoCmd.GoToRecord , , acPrevious
End If
0
 
LVL 4

Expert Comment

by:Clothahump
ID: 18048515
Agreed.  Either put in the Else or change it to


If NOT rst.BOF Then
        DoCmd.GoToRecord , , acPrevious
End If
0
 

Author Comment

by:skennedy10
ID: 18048520
OK, I added the "Else" and I was able to move backward until I got to 1, then on that click I get this error:  

Runtime error '2105':You cannot go to the specified record.  --the same thing that I get without all this recordset clone stuff and BOF!  

It just does not seem to evaluate when it is at BOF right.  

What causes that?
Susan
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Expert Comment

by:dan_vella
ID: 18048567
What is your aim with this? You could just use

DoCmd.GoToRecord , , acPrevious

on its own if navigation is the only purpose
0
 

Author Comment

by:skennedy10
ID: 18048601
I don't want an error message  (the runtime error 2105) if already at the first record and the user hits Previous Record button.  

I have done the NOT rst.BOF then ..... also, and it just does not seem to pick up on being BOF!  

I noticed that there are ADO and DAO recordset types and that they are different.  Do I have the wrong one?  I get past that in code stepping, so I assumed I had that right.  

Susan


0
 
LVL 4

Accepted Solution

by:
dan_vella earned 250 total points
ID: 18048628
Susan,

Using the default previous button via the MS Access wizard accomplishes this, unless there was something else you need the code to do.

It gives the default message "Can't go to the specified record".
0
 

Author Comment

by:skennedy10
ID: 18060396
Gentlemen,
Thanks for all of your help.  I figured out that I had gone to Tools/Options/General and had checked "Break on unhandled errors."  

This was not letting the BOF "normal message" you thought I was referring to show.  I was getting the one that told me that I had an error (with #) and was asking to either end or debug, which I don't want the user to have to deal with.  

Thanks!
Susan
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now