Save as file

M

Martin Gustavsson

I want to be able to save data on a form as a file. I have a form with a
standard text and with individual names (from db). I want to be able to save
one file for each person containing that persons name. The filename should
be the same as the person "in" the file.
Is this possible?

Thank's
 
B

Brendan Reynolds \(MVP\)

The details would depend on the type of file you want, but the following
example saves a text file, with the contents of each control on a separate
line, in the same folder as the application ...

Private Sub cmdSaveToFile_Click()

Dim intFile As Integer
Dim strFile As String

intFile = FreeFile
strFile = CurrentProject.Path & "\" & Me!txtCustomerName
Open strFile For Output As intFile
Print #intFile, Me!txtContactName
Print #intFile, Me!txtCustomerAddress
Print #intFile, Me!txtPhoneNumber
Close intFile
Shell "notepad.exe " & strFile

End Sub
 

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