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

Insert Text in NotePad 1

Status
Not open for further replies.

evalesthy

Programmer
Joined
Oct 27, 2000
Messages
513
Location
US
I am creating a document using TransferText method:

DoCmd.TransferText acImportDelim, "071703 Import Spec", "Budget", varImportFileName

I then open the document in NotePad for user to review.

What I want to do is insert two lines at the top of the document (line 1 and line 2) for a ProjectName and a ProjectNumber that would be picked up from 2 text fields on the form that the TransferText process is run from.

How would I go about this? Thanks.
 
If you are creating a text document from a table within your DB then you will have to use the acExportDelim
instead of the acImportDelim like you have posted above. Unfortunately with the Transfertext method it will overwrite the file that you point to so you can't add the text to the file first but you could do this in a round about way, try something like this:

Dim filename As String, s As String

filename = "C:\temp.txt"
Open varImportFileName For Output As #1
Print #1, Me.txtProjectName
Print #1, Me.txtProjectNumber
Print #1,
Close #1

DoCmd.TransferText acExportDelim, , "Budget", filename
Open varImportFileName For Append As #1
Open filename For Input As #2

While Not EOF(2)
Line Input #2, s$
Print #1, s$
Wend
Close
Kill filename


Let me know if this helps.

Regards,
gkprogrammer
 
That looks like it will do exactly what I want. I will test it later today and post back if I have any questions. Thank you.

p.s. You are right - it is 'acExportDelim'. In my haste to post last night I copied the wrong line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top