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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to display the contents of a TextFile inside a TextBox?

Status
Not open for further replies.

MPBCHM

IS-IT--Management
Feb 6, 2002
20
0
0
US
I have a FORM, with a TEXTBOX and a LISTBOX

Senario:
My listbox has the names of textfiles found on my hard drive. When I double click on a selected textfile, I would like to view the contents of that textfile in my textbox. Also, if possible, I would like to make changes to that textfile and Word Wrap the displayed text.

I have had no luck in the FAQ's and Forum Searches...
Your help would be greatly appreciated.

Thanks in advance.

Mark
 
You can do this. First, though, you'll need to realize that you will probably need to insert the contents of the file into a MEMO field in a record.

You will probably have to work up a sample IMPORT spec and use it via some VBA code.

However, I see no way to mimic a Word Wrap process, whereby the lines wrap around given a reduction in the text control's width. It's hard to do that anyway - controls tend to want to be fixed in size.

There may however, be 3rd party or ActiveX controls that perform word wrapping. Check out some of the better known Access add-in vendors like FMS.

Jim How many of you believe in telekinesis? Raise my hand...
Another free Access forum:
More Access stuff at
 
Thanks for the response...

The word wrap part of it I could live without but its the import part thats got me. Any suggestions on how I can get the text file to open up in a textbox. I had thought about creating BMP images of each document and then using the OLE object box to dislay the images. But this wouldn't work as my text files change at random.

Thanks for the help...

Mark
 
Question: is this/these a 'plain text' file - in other words just text, no WORD crap, no WordPerfect paired code or other nonsense? Just plain ol' ASCII text?

If so, you can probably do this:

1) create a table, with ONE text field of 255 characters.

Use this table as the destination for an import spec process. Each line in the text file will become a RECORD in the new table.

If a sample file has 200 lines, you will get 200 records.

Next, write a small proc that will cycle through the records, appending them to a MEMO field in another table. I suppose you could join by some autonumber or the file name or something.

Public Sub BuildMemoField()
Dim rs1 as recordset
dim rs2 as recordset

set rs1 = CurrentDB.OpenRecordset({your text table guy})
set rs2 = CurrentDB.OpenRecordset({your table with the MEMO field})

RS2.ADDNEW
RS2!keyfield = ???? <--- don't know exactly how you're doing this part
RS2!Memofield = &quot; &quot; <-- toss an empty space in the memo field to start with

rs1.MoveFirst
while NOT RS1.BOF
Do
rs2.Memofield = rs2.MEMOFIELD & rs1.TextLine
rs1.MoveNext
Loop
RS2.UPDATE

{and then clean up....)


This should create a memo field from all the various LINES in the other table, concatenated together. You may need to toss a space or something in there between lines, too. Depends on what the lines of text look like.

Do you get the idea here?

Jim















How many of you believe in telekinesis? Raise my hand...
Another free Access forum:
More Access stuff at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top