Solved

acNext takes me to blank record

Posted on 2000-03-23
7
528 Views
Last Modified: 2012-05-04
I'm using a button on a form to move to the next record. I placed the code DoCmd.GoToRecord , , acNext behind the button. It works fine except users are able to scroll through all the records until they get to the end and then it's blank. However, acLast does not take them to a blank record. How can I get acnext to stop vefore it goes to far. The problem is they are going to the blank record and trying to enter new records there instead of using the add records button.
0
Comment
Question by:scully12
7 Comments
 
LVL 1

Accepted Solution

by:
Viesturs earned 50 total points
ID: 2649675
You can insert before
DoCmd.GoToRecord , , acNext
the code
Me.AllowAdditions = False
where Me is Active form
and when you wish
DoCmd.GoToRecord , , acNewRec
then insert before
Me.AllowAdditions = true.

Maybe this can help.
0
 
LVL 2

Expert Comment

by:goyam
ID: 2649715
Hi,
you may test if you are on the last record:
If Me.CurrentRecord <> Me.Count Then
    DoCmd.GoToRecord , , acNext
End If
Regards
0
 
LVL 7

Expert Comment

by:Dedushka
ID: 2649769
Hi scully12.
You can just go back to previous record:
Private Sub Command12_Click()
  DoCmd.GoToRecord , , acNext
  If Me.NewRecord Then DoCmd.GoToRecord , , acPrevious
End Sub

Good luck,
Dedushka
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 2

Expert Comment

by:goyam
ID: 2649805
Sorry, I wanted to write
If Me.CurrentRecord <> Me.RecordsetClone.RecordCount Then
        DoCmd.GoToRecord , , acNext
End If
 and not Me.count
Best regards
0
 
LVL 2

Expert Comment

by:goyam
ID: 2649806
Sorry, I wanted to write
If Me.CurrentRecord <> Me.RecordsetClone.RecordCount Then
        DoCmd.GoToRecord , , acNext
End If
 and not Me.count
Best regards
0
 
LVL 6

Expert Comment

by:cjswimmer
ID: 2649945
Viesturs has it.  Just turn off AllowAdditions and then turn it on through code when you press the AddRecord button.  
You probably already have this, but you should probably capture the EndOfRecordset error when you use those buttons.  Those are the errors you will get if you try to go past the last record, or go to a record before the first one with those buttons.
In the NextRecord button code:

Sub btnNextRecord_Click()
On Error Goto errorhandler
  DoCmd.GoToRecord , , acNext
Goto SkipErrorhandler:
ErrorHandler:
  Select Case err.number
  Case 2105
  Case Else
     msgbox "Err# " & err.number & vbCrLf & err.description
  End Select
  Resume Next
SkipErrorHandler:  
End Sub

You can use this in the Previous button code to, just change the gotoRecord argument to acPrevious

Hope this helps---CJSWIMMER
0
 

Author Comment

by:scully12
ID: 2650681
I think any of the answers I was given would have worked so thanks to everyone. However, I went with Viesturs answer for whatever reason. Thanks,
Scully12
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

758 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

19 Experts available now in Live!

Get 1:1 Help Now