473,414 Members | 1,626 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,414 software developers and data experts.

custom nav buttons: no current record error?

AccessIdiot
493 256MB
Please see attached screen shot. As you can see I have a main form (DPR_Main) with a subform (DPR_Survey). Within the subform is another subform (DPR_Resources).

I am using the following code I grabbed off the interwebs for the unbound textbox (called txtRecordNo) that acts as a record count:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. Dim rst As DAO.Recordset
  3.     Dim lngCount As Long
  4.     Set rst = Me.RecordsetClone
  5.     With rst
  6.         .MoveFirst
  7.         .MoveLast
  8.         lngCount = .RecordCount
  9.     End With
  10. Me.txtRecordNo = "Record " & Me.CurrentRecord & " of " & lngCount
  11. End Sub
  12.  
I have this on all three forms.

For the three nav buttons I have the following code (again on all three forms):
Expand|Select|Wrap|Line Numbers
  1. Public Sub Next_Record()
  2. On Error GoTo Err_Next_Record
  3.  
  4. With Recordset
  5.   If .AbsolutePosition = .RecordCount - 1 Then
  6. 'you are on the last record
  7.         DoCmd.GoToRecord , , acFirst
  8.   Else
  9. 'you are on some other record
  10.         DoCmd.GoToRecord , , acNext
  11.   End If
  12. End With
  13.  
  14. Exit_Next_Record:
  15.     Exit Sub
  16.  
  17. Err_Next_Record:
  18.     MsgBox Err.Description
  19.     Resume Exit_Next_Record
  20. End Sub
  21. -------------------------------
  22. Private Sub cmdAdd_Click()
  23.     DoCmd.GoToRecord , , acNewRec
  24. End Sub
  25.  
  26. Private Sub cmdNext_Click()
  27.     Call Next_Record
  28. End Sub
  29. ------------------------------
  30. Private Sub cmdPrevious_Click()
  31. If Me.CurrentRecord > 1 Then
  32.     DoCmd.GoToRecord , , acPrevious
  33. Else
  34.     MsgBox "You are at the first record!", vbOKOnly, "Warning!"
  35. End If
  36. End Sub
  37.  
The next buttons work great on the Cultural Resources section and the DPR (main) section. On the Survey section I get an error that says "Run-time error '3201': No current record." When I debug it highlights the .MoveFirst or sometimes the.MoveLast part of the first code section posted above.

The Add New button works only on the Cultural Resources section. The Previous button works fine.

What am I doing wrong? I mean, besides trying to hack together code I don't fully understand that is.

I am using MS2007 but saving as an 03 mdb, as that will be what our field crews will be running.
Attached Images
File Type: jpg Screenshot_1.jpg (55.7 KB, 230 views)
Sep 22 '10 #1
3 1792
AccessIdiot
493 256MB
Never mind, I'm an idiot. Apparently I just needed
Expand|Select|Wrap|Line Numbers
  1. If rst.RecordCount <> 0 Then
  2.  
in the Form_Current
Sep 22 '10 #2
Mariostg
332 100+
Did you run with a breakpoint to follow a step by step execution to find out where the error occurs?
I have a strange feeling that lngCount = .RecordCount might return -1, unless you specify the option adOpenStatic (At least in Access 2003).
Sep 22 '10 #3
AccessIdiot
493 256MB
Thanks for the reply - what I did seems to work but if it barks at me again I'll hit you up for a further explanation of your suggestion. :-)
Sep 22 '10 #4

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

Similar topics

4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
2
by: Paul Mendez | last post by:
I have a form that consists of 150 records and is still growing. there are times when I want to print a certain record of the form, say record 12. I go to file --> print and choose the page number...
1
by: xmp333 | last post by:
Hi, I have a form that is designed as a data sheet view. Attached to this is a subform with some VB code. When the user clicks on a row, the subform should pop up and run the VB code which...
2
by: Weaver | last post by:
Seems like this ought to work: Set rs = Me.RecordsetClone rs.Bookmark = Me.Bookmark rs.Edit rs.Delete rs.Update Set rs = Nothing Exit Sub
2
by: dixie | last post by:
Can someone please give me the error number for this error? dixie
3
by: hebandgene | last post by:
When I delete a record in a subform I get the warning that I'm about to delete a record, followed by an error "No current record." When I click OK obviously the record is deleted and it goes to...
8
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
2
by: capdownlondon | last post by:
using ACCESS 2003 This code should do what I want, and it seems to, but every time i run it it says: No Current Record when i ctrl+break it the debug get hung up on the end sub. heres the...
2
by: Tom Clavel | last post by:
Scratching my head. I am using the filter property on a combo box .AfterUpdate event to get to a single client record. This is causing a some strange behavior: As I enter a subform, I get a no...
2
by: Ian | last post by:
I am trying to save the current record on a form before opening a report, doesn’t sound to hard does it? The code on a buttons on click event goes like this: DoCmd.DoMenuItem acFormBar,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.