GENERATE a TEXT FILE Using INPUT from a Form ??

  • Thread starter kev100 via AccessMonster.com
  • Start date
K

kev100 via AccessMonster.com

I need to generate a Text file using (partly) information entered by the user
on a form.

I already have the TEMPLATE for the text file......I need to generate a COPY
of the file with the word entered by the user into the form INSERTED into the
text file.

The text file is actually code for a web page (will have an .htm extension).

The file is simply an exact copy of an existing template with only ONE ITEM
of the text changed to a word that is entered into a form by a user.

Example:

One line within the template file is:

"We have several of these items available in BLUE."

I have a form into which a user can input a color (e.g. red, blue, green, etc)
 
J

John W. Vinson

I need to generate a Text file using (partly) information entered by the user
on a form.

I already have the TEMPLATE for the text file......I need to generate a COPY
of the file with the word entered by the user into the form INSERTED into the
text file.

The text file is actually code for a web page (will have an .htm extension).

The file is simply an exact copy of an existing template with only ONE ITEM
of the text changed to a word that is entered into a form by a user.

Example:

One line within the template file is:

"We have several of these items available in BLUE."

I have a form into which a user can input a color (e.g. red, blue, green, etc)

Take a look at the VBA help for TransferText. Since we have no way to know
anything about the structure of your Access database, where the rest of the
text comes from, or what the output should look like, it's more than a bit
hard to be specific.

John W. Vinson [MVP]
 
N

nartla

I need to generate a Text file using (partly) information entered by the user
on a form.

I already have the TEMPLATE for the text file......I need to generate a COPY
of the file with the word entered by the user into the form INSERTED into the
text file.

The text file is actually code for a web page (will have an .htm extension).

The file is simply an exact copy of an existing template with only ONE ITEM
of the text changed to a word that is entered into a form by a user.

Example:

One line within the template file is:

"We have several of these items available in BLUE."

I have a form into which a user can input a color (e.g. red, blue, green, etc)


I don't really understand what is your problem, but I suggested you
create a string value like this :

Dim myString, resultingString, custColor as String

myString = "We have several of these items available in CHOOSENCOLOR."

Once you've obtained the color choosen by your customer and stored it
in the custColor string, you just need to do :

resultingString = Replace (myString,"CHOOSENCOLOR", custColor)

Maybe this will help you ...
 
R

Roger Carlson

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "CleanFileHTML.mdb" which you should be able to modify for
your purposes. As is, it searches for and removes HTML tags from a text
file. It does this by reading the original file (your template) one
character at a time and writes them to a new file. It searches for "<" ">"
combinations to remove tags, but you could modify it to look for some other
marker and insert your user input there.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
D

Douglas J. Steele

nartla said:
I don't really understand what is your problem, but I suggested you
create a string value like this :

Dim myString, resultingString, custColor as String


You may be unaware of the fact that

Dim myString, resultingString, custColor as String

only declares custColor as a String: myString and resultingString will be
Variants.

To have all three as strings, you need

Dim myString As String, resultingString As String, custColor As String
 
K

kev100 via AccessMonster.com

Thanks very much for all replies....I am checking each now....particularly
yours, Roger.

---------------------------


The source/location of the template text could be just about anywhere. It is
about 1 page-worth at a 10-point arial font.

The template text is current in a txt file.....but could also reside on the
actual form itself in a unbound text box (if this would help).

I have initially played around with such (pasting the text into an unbound
text box)....and simply using [formname.UserColor] at the point in the text
where the user color needs to appear...then trying to output the contents of
that text box to a text file via a macro.

However, it did not seem to want to insert the value of [formname.UserColor]
at that point in the text...it just displays the literal "[formname.UserColor]
".

(this admittedly may be wrong thinking altogether).


Roger said:
On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "CleanFileHTML.mdb" which you should be able to modify for
your purposes. As is, it searches for and removes HTML tags from a text
file. It does this by reading the original file (your template) one
character at a time and writes them to a new file. It searches for "<" ">"
combinations to remove tags, but you could modify it to look for some other
marker and insert your user input there.
I need to generate a Text file using (partly) information entered by the
user
[quoted text clipped - 21 lines]
I have a form into which a user can input a color (e.g. red, blue, green,
etc)
 
N

nartla

You may be unaware of the fact that

Dim myString, resultingString, custColor as String

only declares custColor as a String: myString and resultingString will be
Variants.

To have all three as strings, you need

Dim myString As String, resultingString As String, custColor As String

You're right. I'm more a C++ programmer, so I am afraid I know more C+
+ style variables definition where :

int a,b,c is allowed ... ;-)
 
G

Guest

I have created VBA code in an application to:

- Open a specific file in a specific directory
- Spin through the file until I find the line I want (writing each line to
an output TXT file as I go)
- Modify the specific text in the specific line and output that changed line
to the text file
- Spin through the rest of the file, writing the lines to an output file
- Closing the input and output files when done

If this is what you want to do, and if you can't find the answers you seek
in the others' suggestions, email me at:

(e-mail address removed)

I'll copy/paste my VBA code into a response.

Dennis



kev100 via AccessMonster.com said:
Thanks very much for all replies....I am checking each now....particularly
yours, Roger.

---------------------------


The source/location of the template text could be just about anywhere. It is
about 1 page-worth at a 10-point arial font.

The template text is current in a txt file.....but could also reside on the
actual form itself in a unbound text box (if this would help).

I have initially played around with such (pasting the text into an unbound
text box)....and simply using [formname.UserColor] at the point in the text
where the user color needs to appear...then trying to output the contents of
that text box to a text file via a macro.

However, it did not seem to want to insert the value of [formname.UserColor]
at that point in the text...it just displays the literal "[formname.UserColor]
".

(this admittedly may be wrong thinking altogether).


Roger said:
On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "CleanFileHTML.mdb" which you should be able to modify for
your purposes. As is, it searches for and removes HTML tags from a text
file. It does this by reading the original file (your template) one
character at a time and writes them to a new file. It searches for "<" ">"
combinations to remove tags, but you could modify it to look for some other
marker and insert your user input there.
I need to generate a Text file using (partly) information entered by the
user
[quoted text clipped - 21 lines]
I have a form into which a user can input a color (e.g. red, blue, green,
etc)
 
K

kev100 via AccessMonster.com

Thanks very much Dennis.....I may very well do that.

I've had to put this off for a few days...but will follow up asap.

Thanks
I have created VBA code in an application to:

- Open a specific file in a specific directory
- Spin through the file until I find the line I want (writing each line to
an output TXT file as I go)
- Modify the specific text in the specific line and output that changed line
to the text file
- Spin through the rest of the file, writing the lines to an output file
- Closing the input and output files when done

If this is what you want to do, and if you can't find the answers you seek
in the others' suggestions, email me at:

(e-mail address removed)

I'll copy/paste my VBA code into a response.

Dennis
Thanks very much for all replies....I am checking each now....particularly
yours, Roger.
[quoted text clipped - 31 lines]
 

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