Need Help on User-Defined Type

  • Thread starter Montana DOJ Help Desk
  • Start date
M

Montana DOJ Help Desk

Word 2000

I'm trying to create a user-define type. This is the first time I've tried
to do this, so I've been reading through the on-line Help trying to figure
it out. Here's what I have so far:

********************
' Code placed in a standard module containing only public declarations.
Type ErrorRecord
ErrDateTime As Date
ModuleName As String
Subroutine As String
ErrNumber As Long
ErrHelpContext As Long
ErrDescription As String
ErrHelpFile As String
End Type

' Code placed in the routine.
Dim ErrorRecord As ErrorRecord

With ErrorRecord
.ErrDateTime = ErrDateTime
.ModuleName = ModuleName
.Subroutine = Subroutine
.ErrNumber = Err.Number
.ErrHelpContext = Err.HelpContext
.ErrDescription = Err.Description
.ErrHelpFile = Err.HelpFile
End With

FileNumber = FreeFile
Open ErrorLog For Random As FileNumber Len = Len(ErrorRecord) + 2

Put #FileNumber, , ErrorRecord
********************

On the PUT statement I get:

Run-time error '59':
Bad record length

From reading the Help on this error, I understand what the problem is, but
I'm having difficulty determining how to set the proper record length.
Hopefully, I've provided enough information for someone to answer my
question. Given the above, how do I get the record length set properly?

-- Tom

State of Montana
Department of Justice Help Desk

"Making the world a safer place."
 
M

Montana DOJ Help Desk

Word 2000

After working on this some more and thinking about it some more, I decided
that it would be best to backup and ask another question, to ascertain
whether or not what I'm trying to do is even possible using the method that
I'm currently trying.

I have a macro that logs errors to a text file. The data being logged looks
like this:

10/21/2004 9:00:07 PM,ThisDocument,TestRoutine,13,1000013,Type
mismatch,C:\PROGRA~1\COMMON~1\MICROS~1\VBA\VBA6\1033\VbLR6.chm

That's...

Date and time,ModuleName,SubroutineName,Error Number, Error Help Context,
Error Description,Error Help File

I've built a user form that contains four navigation buttons, (First,
Previous, Next, and Last), a Close button, and a Help button. The goal is
to be able to write each error to the file as a record, and then to read the
file record by record. Using the navigation buttons on the form, the user
could move back and forth between records. Clicking the Help button would
pull up the Help information on that specific error.

I thought that by writing the data to the file using PUT, and reading it
using GET, I'd be able to do this. But PUT and GET only have 4 arguments,
so I figured that I'd have to put my data into a user-defined type and write
and read the data that way.

Am I on the right track here?

-- Tom

State of Montana
Department of Justice Help Desk

"Making the world a safer place."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top