vba runtime error 59

I am writing a VBA object in Microsoft Word 2003 which displays a form prompting the user to key in a number. A file is then opened and a GET is used to get the record. The OPEN and GET subroutine are in a module. When I delete the module and re-import the module the object runs perfectly. However if I save and close Word and reload word I get an error "runtime error 59 bad record length" on the line "Get FMKEYS,THREEONE,MKEYSREC". If I then delete the module which and reimport the module it will work fine.

Please Help...............

Thanks

Codes....................

Type MKEYSRECTYPE
AKEYNAME As String * 10 ' Alpha key
AKEY As Double ' Relative record
MKSTATUS As String * 1 ' Status (0 = active, 1 = closed)
End Type

Global MKEYSREC As MKEYSRECTYPE
Global THREEONE As Double
Global FMKEYS As Integer

Sub GETMKEYS()
FMKEYS = 3
Open MKEYS$ For Random Access Read Write Shared As FMKEYS% Len = 19
Get FMKEYS, 1, LRMKEYS
If THREEONE < 1 Then
MsgBox ("Bad Record 8031 "), 48
Else
Get FMKEYS, THREEONE, MKEYSREC
End If
Close FMKEYS
End Sub



Answer this question

vba runtime error 59

  • vba runtime error 59