hello--
i am having trouble figuring out how to export individual records from an Access 2002 Form into a pre-existing Excel spreadsheet, such that the exported record is merely appended to the Excel file, rather than completely overwriting it (as occurs with the basic OutputTo function).
specifically, I am trying to create a macro that "backs-up" any deleted record. So, when someone goes to delete a record (i have a delete-record macro that deletes the selected record on a form via a command button), instead of deleting the record forever, the macro exports the selected record into an Excel file, which will contain a running list of all the deleted records. any thoughts?
thanks,
jason
I have a much simpler and even more practical solution involving only 3 lines of code. Prior to a Record's deletion, run the code below. It will open the specified *.txt File and "append" the relevant data to it in a comma delimited format. This data could then be easily imported into either Access, Excel, or a variety of other applications with a minimal amount of effort. The Import Process could be easily automated. The other option would probably be complex Automation Code. The code is listed now for your preview:
- Open "C:\Deleted.txt" For Append As #1
-
Write #1, Me![txtPayrollNumber], Me![txtLastName], Me![txtFirstName], CStr(Me![txtBirthDate])
-
Close #1
The Text File would look something like:
"6537228",#NULL #,"John","3/23/1940"
"9876343","McNa mee","William", "1/26/1947"
"10408564","Alb erici","James", "2/16/1948"
"10567888","Man sfield","Martin ","12/7/1943"
"10637565","Del Rossi","George" ,"11/5/1946"
"10294610","Nob le","Robert", "8/16/1945"
"10954701","McG arrigle","James ","10/3/1947"
"10496556",#NUL L#,#NULL#,"3/17/1949"
"11130747","Dou gherty","Robert ","8/12/1948"
"11355062","Jac kson","Joseph", "1/16/1947"
"87654912","Dez ii","Armund", "3/17/1949"
"17189480","Bla ck","Matthew"," 11/11/1944"
"11484877","Cam pbell","William ","2/12/1946"
"11866509","Gaf fney","William" ,"5/14/1947"
"12304426","Mat arazzo","Vincen t","4/13/1943"
"12321281","Dep osit",#NULL#,"3/17/1949"
"12333079","McC loskey","John", "6/1/1942"
"12639184","Gra nde","Robert"," 5/29/1947"
"13292686","Yae ger","Michael", "12/27/1951"
"71729342","Han son","Francis", "8/18/1942"
"13293862","Car penter","Joseph ","7/22/1943"
"25536800","Sim on","Harry"," 7/17/1948"
"66253599","Sev erio","Robert", "1/6/1992"
"82593570","Fow ler","Fiona"," 3/17/1949"