echobravo316
asked on
How can I save data from a form field?
After I create a basic form lets call it Form1 and it has 2 textbox fields with 1 command button. How can I program the command button to save the text from the two boxes in a text file? I want the form to create a different file for each time the command button is pressed using textbox 1 as the filename. Please explain the steps required. Thnks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim inFileNumber As Integer
Private Sub Command1_Click()
Dim Filename As String
inFileNumber = inFileNumber + 1
Filename = App.Path + "/FileMade.txt" & inFileNumber
Open Filename For Output As #1
Print #1, Text1.Text
Print #1, Text2.Text
Close #1
End Sub
This works.....i've tried it. Make sure the inFileNumber Statement is in the general declarations.
Jacamar.
ASKER
How can I get rid of the quotation marks in the output file?
Declare the following variables in Declaration section:
Public objFSO As FileSystemObject
Public objTextFile As TextStream
Create the following Sub to Write to a textfile:
Public Sub WriteToFile()
strFileName="C:\My Documents\Testing.txt"
Set objTextFile = objFSO.OpenTextFile(strFil
End Sub
'--- strFileName is the file name where you want to write the text along with the full path of the file.