Error: No current record (1 Viewer)

sandstone

New member
Local time
Today, 12:52
Joined
Oct 27, 2011
Messages
14
I have a routine that I use frequently to loop through visits on a particular date, building up a Word file of letters for each visit, in alphabetical order for each person visited and, finally, formatting that file and printing it to the screen. However, one one particular day, the routine terminates prematurely without producing the final product, with the error message ‘No current record’. I have tried to identify what is happening by stepping through the code but have been unable do so. The routine works perfectly when other dates are entered and I am wondering if, on the date in question, it has encountered data either omitted or incorrectly entered within a field with which it cannot deal. I am unsure how to go about identifying the record of the relevant person.

Help greatly appreciated.
 

ebs17

Well-known member
Local time
Today, 13:52
Joined
Feb 7, 2020
Messages
1,946
I am wondering if, on the date in question, it has encountered data either omitted or incorrectly entered within a field with which it cannot deal
Yes, you should answer questions like that.
When you can see clearly again - look at your screen.
 

LarryE

Active member
Local time
Today, 04:52
Joined
Aug 18, 2021
Messages
591
On Error Resume Next
at the beginning of your code will help with the error
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:52
Joined
Feb 28, 2001
Messages
27,186
The solution is to leave a trail of bread crumbs. (The "Hansel and Gretl" solution.)

Add a logging table in which you can write notes to yourself. Since this is a loop, write a new entry for each step through the loop, telling you where you are in the file you are processing. Record your progress. When this routine terminates, check for the last bread crumb. See where that takes you. SOMETIMES when using this approach, you have to iterate the attempts because you find that you need to add another logging statement or two to refine the path of crumbs. After each iteration and before repeating the test, clear out the table of bread crumbs. Be sure that in your code, you make it easy to find the logging statements so that when you are done with this problem, you can yank out the individual logging statements and stop the logging.
 

sandstone

New member
Local time
Today, 12:52
Joined
Oct 27, 2011
Messages
14
Thank you all for your help. I tried substituting 'On Error Resume Next' for the usual error code and the subroutine paused at the same point with the error message 'Automation error'. It then continued to format the Word file and print it to the screen, but with an additional formatted letter containing some of the data from the previous person. I'm not sure where to go from here.
 

ebs17

Well-known member
Local time
Today, 13:52
Joined
Feb 7, 2020
Messages
1,946
On Error Resume Next
at the beginning of your code will help with the error
Can you see better with your eyes intentionally closed? Not in my world, you have to look - and every error is one too many.

error message ‘No current record’
That's a thick bread crumb, more like a boulder.

You determine the code location where this error occurs and look for something that uses records and cannot do anything with an empty recordset and throws an error, e.g. a MoveLast (for a RecordCount).
 

sandstone

New member
Local time
Today, 12:52
Joined
Oct 27, 2011
Messages
14
Thanks, once again, for your help. I managed to trip over the boulder - it turned out to be a visit type that would normally result in skipping over that record to the next record but, in this case, it was the last record in the recordset. This would not usually occur, but the visit type had been incorrectly entered.

Sorry if I seemed to be wanting a quick fix without putting in the effort. I wrote this code, which is part of a large application over 20 years ago and I am amazed that it has continued to serve me well, with only occasional tweaks, despite all the progress that has occurred in that time and the necessity to move it when hardware was upgraded. I was an enthusiastic amateur originally but my day job prevented me from devoting the necessary time to it, so that I have become quite rusty. This forum has always been very helpful when I have encountered problems over the years.
 

Users who are viewing this thread

Top Bottom