Trouble With Copied Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Thanks for taking the time to read my question.

I went to this site http://www.mvps.org/access/modules/mdl0057.htm for some
code to help me import files into my db.

The problem is that the copied code gets stuck at this line:

Dim myTextFile As New clsReadTextFile ' Create a new class internal to
your program.

which appears in the sample provided by Chuck. The Error I get is
"User-Defined type not defined". Why is this happening, and how can I fix
it. I tried e-mailing Chuck, but the address doesn't work.

Thanks again.
 
Looks like there a CLASS module that you need as well. Recheck the page
for information on implementing the example.
 
That's what I thought. I've read through the pages provided, but I don't see
anything.

At the top of the file to copy is this:

Option Explicit
' Attribute VB_Name = "clsReadTextFile"
' Text File Class for reading files
' Copyright 2000, Chuck Grimsby
' All Rights Reserved
' Use is free without restriction,
' I just keep the copyright!

I took off the REM from the first line " ' Attribute VB_Name =
"clsReadTextFile", but that just gave me an error.

Any other ideas?

Thanks again for the reply,

Brad
 
Sounds as though you're creating a Module, when you need to copy that code
into a Class.
 
Brad said:
That's what I thought. I've read through the pages provided, but I don't see
anything.
[]


Brad, I believe that the code needs to be copied into a
**Class** module within your application.
 
That sounds correct. I've been reading a post at
http://www.developersdex.com/vb/message.asp?p=2899&r=4273557&Page=1

that says the same thing, but I can't seem to get it to work.

The suggestion was to copy the code to a .txt file and save it. Then in the
Immidiate window paste:
Application.LoadFromText _
acModule,"clsReadTextFile", _
"clsReadTextFile.txt"

Apparently you only have to do that once, then you're good. Still can't get
it to work.

I signed up there, and am going to try a post there too. Maybe Chuck is on,
and can lend a hand.

Thanks,

Brad
 
Select Insert | Class Module from the menu. For Access 2000 and newer, you
must be in the VB Editor to do this.
 
Back
Top