473,395 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

cmdNext Error Msg not working

I have the following code for a next record button in an access form that won't bring up msgbox after last record is reached.

Expand|Select|Wrap|Line Numbers
  1. On Error goTo_cmdNext_click
  2. DoCmd.GoToRecord, , acNext
  3. Exit_cmdNext_click
  4. Exit Sub
  5. Err_cmdNext_click
  6. Msgbox "No more records etc.", , "Last record"
  7. Resume Exit_cmdNext_click
  8. End Sub
  9.  
Please assist,
Jason
Apr 11 '13 #1
3 1129
Seth Schrock
2,965 Expert 2GB
The error is in the second line of your code. It needs to be
Expand|Select|Wrap|Line Numbers
  1. On Error GoTo Err_cmdNext_Click
You are also missing a few colons. Try the following code
Expand|Select|Wrap|Line Numbers
  1. On Error GoTo Err_cmdNext_click
  2.  
  3. DoCmd.GoToRecord, , acNext
  4.  
  5. Exit_cmdNext_click:
  6.     Exit Sub
  7.  
  8. Err_cmdNext_click:
  9.     Msgbox "No more records etc.", , "Last record"
  10.     Resume Exit_cmdNext_click
  11. End Sub
Apr 11 '13 #2
The only difference I see is the capital C in click. that was a typo, the actual code does have a capital C but it still doesn't work.
If I'm missing something completely here please dummy it down for me.
Apr 11 '13 #3
Seth Schrock
2,965 Expert 2GB
Line numbers are referencing my code.
Line 1: You have goTo_cmdNext_click. You can't have the GoTo connected to the line you want to go to. Also, the name of the line is actually Err_cmdNext_click. So I put GoTo Err_cmdNext_click.

Lines 5 and 8. You have to have colons at the end of the name. Otherwise, Access thinks that it is either a variable or a procedure that you are trying to call.

I'm guessing (almost sure) that you don't have option explicit set. See Require Variable Declaration on why you need it and how to make it set automatically.
Apr 11 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: GRoll21 | last post by:
Hey this is my first time posting on of these. the program just gets the employee number, then it gets hours, how much they get paid, then figures total. for some reason its not liking my last...
2
by: Galina | last post by:
Hello I have a very complex database application, which have been working fine for several years in Access 97. Now I had to convert it into Access 2000. The main form (course) has got 2 subforms....
1
by: DebbieG | last post by:
The following code works great for me (a single PC); however, when I install the front-end on the client's PC and the back-end on a network drive it is not working -- ie, the Save and Undo buttons...
2
by: longtim | last post by:
I have been trying to implement navigation buttons for a number of forms in my application. Creating the 'Next' 'Previous' buttons has been fine but setting the enabled properties doesn't work...
0
by: tfs | last post by:
I have loaded my .doc files (word documents) into my Sql 2000 server. I am trying to read and display the doc files in my ASP page. The error I get is Internet Explorer cannot download...
2
by: MirzaSila | last post by:
Hear is the part of code: Dim db As DAO.Database Dim rst As DAO.Recordset Set db = CurrentDb() Set rst = db.OpenRecordset("SELECT FirstName FROM People WHERE LastName = " & LastName & "") ...
1
by: bhavika123456 | last post by:
Private Sub cmdsave_Click() rs.Fields("Emp_id") = cmbempid.Text rs.Fields("Absent_date") = lbldate2.Caption//it shows here If optabsent.Value = True Then rs.Fields("Emp_status") = "absent" ...
18
by: OldBirdman | last post by:
I have a listbox named lbxSelect which has RowSource = strSQL set in VBA code. This displays correctly on my form (fAAA). Once displayed, I want to use it to select a record, and display the...
0
by: t0rmed | last post by:
I am currently creating my project for visual basic, which is particularly a database. However, error code 3021 shows up when I click delete even though I do not have a database. How could I solve...
7
gskoli
by: gskoli | last post by:
Error - working in IE and MOzilla but giving error null or not a object: Guys i am giving you snippet of code , where it is javascript digital clock , It is showing time and working properly but...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.