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

Adding Results to a text file

Status
Not open for further replies.

tani1978

MIS
Sep 29, 2005
49
DE
I have several forms in my database which show results in unbound textbox.What I want is to save these results in a text file.With my code a text file is generated but the problem is how to show the results?
This statement shows result in the unbound textbox
Code:
me.txt1= me.txt1 & vbnewline & "Showing " & counter & "   " & zahl1 & " in the text file."
Code:
Private Sub Command12_Click()


Dim iFileNumber As Integer
Dim sFilename As String
Dim sDirectory As String
Dim sYourString As String
Dim sYourString2 As String
Dim hello As String

sDirectory = "C:\" & hello
sYourString = "CaseNo: "
sYourString2 = "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"

sFilename = Trim(Str(Year(Now()))) & "_" & Trim(Str(Year(Now()))) & "_" & Trim(Str(Month(Now()))) & "_" & Trim(Str(Day(Now()))) & ".txt"

iFileNumber = FreeFile

If Dir(sDirectory, vbDirectory) = "" Then MkDir (sDirectory)

Open sDirectory & sFilename & ".txt" For Append As iFileNumber
Print #iFileNumber, sYourString
Print #iFileNumber, sYourString2
Close #iFileNumber
End Sub
 
Using the sort of syntax you have, you would need to open the file for Input, then use the "Input" method to fill a variable.

Once you have that variable filled, you can write it to your text box.

I would look at the FileScripting object though. It will probably be more powerful and robust for what you want to do.
 
The problem is I am not familiar with input method and in the internet there is no help provided in a brief way. Can you post me your suggestion how you would use the input method and fill the variable or when you know any internet link about using input method.Thanks
 
Thanks for your help I got it as I wanted. Instead of append I have used Input and then I filled the variable and it worked quite nice.Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top