Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Access files error 59 strange problems

Status
Not open for further replies.

dkellygb

IS-IT--Management
Aug 28, 2001
18
0
0
GB
I need to read from random access files and write them to access to do analysis on a legacy system's data. I have written the code and all seems to work fine for about a week and then bingo! I start getting run-time error 59 bad record length on a GET statement.

Repairing and compacting the database does not help. The only thing which makes it go away is to create a new database and import all the objects into it. This is very annoying. Has anyone else experienced this type of problem? Code snippet is below:

Dim AuditRec As AuditTrail
Dim RecLength As Long
Dim CostDate As Date
Dim AuditFile As String

CostDate = Me.HotDate


AuditFile = "j:\fokus\daily\" & Format(CostDate, "yy-mm-dd") & ".hst"

RecLength = Len(AuditRec)
Open AuditFile For Random Access Read As #1 Len = RecLength

Do While Not EOF(1)
Get #1, , AuditRec 'This is where it fails
'do the analysis
loop
close #1

 
Sorry, I have NO idea.
Does AuditTrail type, require a reference,
to a particular library?
Is it missing?

Maybe to circumvent the crashing,
do you have substantial error handling?
 
The AuditTrail type is the file layout for the random access file. It requires no reference. Here it is for your information:

Type AuditTrail
ID As String * 1
AudDate As Date
AudTime As String * 5
CostCentre As Integer
User As Byte
AudRef As Long
NetAmt As Currency
VATAmt As Currency
ServAmt As Currency
GrossAmt As Currency
RoomNo As String * 4
GuestName As String * 15
PayMethod(1 To 4) As Integer
PayAmt(1 To 4) As Currency
Change As Currency
UserRef As String * 15
PaxTot As Integer
TotAccom As Currency 'NEW****
LedgerCode As String * 6
ExtraDet As String * 20
Spare As String * 28
EPOSFlag As String * 1
End Type
 
I don't believe you're using the AuditTrail type, correctly.

It should be, something like

Get #1, , AuditRec.CostCentre

or

Get #1, , AuditRec.RoomNo

It's been a while, but I believe so.
 
The way I am doing seems to match the help and works in several other programs. The question is why does this work for two weeks and then stop working with a runtime error 59? Why can I fix it by importing the program and objects into a new database?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top