Okay. We'll give it a shot, anyway. Here's how to do it:
1. Read up in Access help, or a good Access book, to get (a little) comfortable with the VBA interface and structure, a little bit about class modules behind forms, and about the syntax for referring to form controls, etc. I just can't take the time it would take to explain all that to you. (Tho obviously if as you work through this you have specific questions, I and others can help you answer them.)
2. Create a new module (not behind a forum, just a regular old module, off the db window). Open it in the VB Editor (double-click the module, or whatever). You'll want to paste the following code into that module (sorry if you have to scroll over in your browser to read a line or two, I didn't want it to break lines):
Code:
Public Sub Write_Log_File(ByVal pstrFilNm As String, _
ByVal pstrLog As String, _
Optional ByVal pblePathInFilNm As Boolean = False)
Dim fsoSysObj As New FileSystemObject
Dim filTxtFile As File
Dim txsStream As TextStream
Dim strPath As String
Dim strFilAndPath As String
If Not pblePathInFilNm Then
strPath = CurDir & "\"
strFilAndPath = strPath & pstrFilNm
Else
strFilAndPath = pstrFilNm
End If
On Error Resume Next
Set filTxtFile = fsoSysObj.GetFile(strFilAndPath)
If Err <> 0 Then
Set filTxtFile = fsoSysObj.CreateTextFile(strFilAndPath)
Set filTxtFile = fsoSysObj.GetFile(strFilAndPath)
End If
On Error GoTo 0
Set txsStream = filTxtFile.OpenAsTextStream(ForAppending)
txsStream.WriteBlankLines 3
txsStream.WriteLine Now
txsStream.WriteLine "---------------------------------------------------"
txsStream.Write pstrLog
txsStream.WriteBlankLines 3
txsStream.WriteLine "---------------------------------------------------"
txsStream.Close
MsgBox "Text file written to " & filTxtFile.Name
Set filTxtFile = Nothing
Set fsoSysObj = Nothing
End Sub
This is a generic procedure which writes any text pstrLog to a file named pstrFilNm; if the variable pstrFilNm contains a path, set pblePathInFileNm to True, otherwise it will write to your current directory (more on this later).
Very important: in order for this code to work, you must set a reference to MS Scripting Runtime. In the VB Editor, choose tools > references. Scroll down until you see it in the list; check it. Choose Debug > Compile afterwards to make sure your code is okay.
3. Now you'll have to write the code in which you send the form contents to the file--the procedure in the form's module that calls the code above. I'm pretending you have three controls on your form called FirstNm, LastNm, and PhoneNum, just for the example--you can use whatever control(s) you want once you get the idea. I'm further pretending that your command button is called cmdWriteRecToTxtFile. You'll need to use your own names, of course. But using mine, the procedure would look about like this:
Code:
Private Sub cmdWriteRecToTxtFile_Click()
Dim strTxt as string
strTxt = Me!FirstNm & vbNewLine _
& Me!LastNm & vbNewLine _
& Me!PhoneNum
Write_Log_File "C:\MyRec.Txt", strTxt, True
End Sub
That's it. You click the button; it will write the contents, as well as some blank lines and stuff around it (you can play with those lines once you understand the code) to a file called MyRec.Txt, on the C root directory. (The same line without directory would read Write_Log_File "MyRec.Txt", strTxt). If the file exists, it adds the record on; if it doesn't exist, the procedure creates it.
Let us know how this works for you, any questions you might have...