Steve - Here is a simple example. While in design view, Put a button named cmdWriteRecord on the form. Select the button and press F7. That will open the VBA editor to the button's click event. Paste in my code. Change the strSQL string to match your table and field names.
Private Sub cmdWriteRecord_Click()
Dim strFile As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strRec As String
Set db = CurrentDb
'Get record from table that matches record on form
strSQL = "SELECT FirstName, LastName, Company " _
& "FROM Customers WHERE ID = " & Me.ID
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
'Concatenate all fields into one string
strRec = rs!FirstName & ", " & rs!LastName & ", " & rs!Company
'Open text file. Create if it doesn't exist.
strFile = "U:\_HOLD\myTextFile.txt"
'Open file for appending
Open strFile For Append As #1
'Write our string to the file
Write #1, strRec
'Clean up pointers
Close #1
Set rs = Nothing
Set db = Nothing
End Sub
-Bill
---In MS_Access_Professionals@yahoogroups.com, <wrmosca@comcast.net> wrote :
---In MS_Access_Professionals@yahoogroups.com, <wrmosca@comcast.net> wrote :
Steve - I didn't forget about you. Just ran out of time. My plan is to use a query on the same source as your form and have the WHERE clause use the same ID as the current row in the form.
Then concatenate the fields into one string and write that string to a text file.
__._,_.___
Posted by: wrmosca@comcast.net
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (7) |
Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.
.
__,_._,___
Tidak ada komentar:
Posting Komentar