473,382 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Export records via macro and append an existing Excel file

6
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
Feb 5 '07 #1
6 6286
ADezii
8,834 Expert 8TB
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:
Expand|Select|Wrap|Line Numbers
  1. Open "C:\Deleted.txt" For Append As #1
  2.   Write #1, Me![txtPayrollNumber], Me![txtLastName], Me![txtFirstName], CStr(Me![txtBirthDate])
  3. Close #1
The Text File would look something like:
"6537228",#NULL#,"John","3/23/1940"
"9876343","McNamee","William","1/26/1947"
"10408564","Alberici","James","2/16/1948"
"10567888","Mansfield","Martin","12/7/1943"
"10637565","DelRossi","George","11/5/1946"
"10294610","Noble","Robert","8/16/1945"
"10954701","McGarrigle","James","10/3/1947"
"10496556",#NULL#,#NULL#,"3/17/1949"
"11130747","Dougherty","Robert","8/12/1948"
"11355062","Jackson","Joseph","1/16/1947"
"87654912","Dezii","Armund","3/17/1949"
"17189480","Black","Matthew","11/11/1944"
"11484877","Campbell","William","2/12/1946"
"11866509","Gaffney","William","5/14/1947"
"12304426","Matarazzo","Vincent","4/13/1943"
"12321281","Deposit",#NULL#,"3/17/1949"
"12333079","McCloskey","John","6/1/1942"
"12639184","Grande","Robert","5/29/1947"
"13292686","Yaeger","Michael","12/27/1951"
"71729342","Hanson","Francis","8/18/1942"
"13293862","Carpenter","Joseph","7/22/1943"
"25536800","Simon","Harry","7/17/1948"
"66253599","Severio","Robert","1/6/1992"
"82593570","Fowler","Fiona","3/17/1949"
Feb 6 '07 #2
jcf378
6
perfect...thanks.
--jason
Feb 6 '07 #3
NeoPa
32,556 Expert Mod 16PB
Nice solution :)
Feb 6 '07 #4
ADezii
8,834 Expert 8TB
perfect...thanks.
--jason
No problemo
Feb 6 '07 #5
ADezii
8,834 Expert 8TB
Nice solution :)
Thanks for the vote of confidence, it is always appreciated.
Feb 6 '07 #6
NeoPa
32,556 Expert Mod 16PB
Hijack post moved to its own thread at Export Access Query into Excel Worksheet.
Jul 15 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Mike MacSween | last post by:
My client has an MS Access database application on her local machine. I have full access to that in terms of changing the design. I've got a simple PHP/MySql application on shared hosting, so no...
0
by: Bryan Russell | last post by:
Hi, My asp/sql server application gets an error, but only when you use the Excel export option: <% Response.ContentType="application/vnd.ms-excel" %> (very popular w/ users) I think...
3
by: Mads Petersen | last post by:
I'm stuck in this code. Hope you can and will help me. I launch it from excel. I have made the following code work, but not as i whant. I need the ranges to be working with something like xlDown....
4
by: sunilkeswani | last post by:
I need help with exporting data from 2 access tables, into 2 existing spreadsheets in a single Excel file. Currently, I am using this code: DoCmd.TransferSpreadsheet acExport, 8, "Table1",...
2
by: Arvind R | last post by:
Hello, how to ask saveas dialog before writing the data to the excel file? right now im able to save in c drive or any other specified location only. any solution will be a great help! ...
14
by: bonehead | last post by:
Greetings, I'm using the DoCmd.TransferText method to export the results of a MS Access query to a csv file. The csv will then be used to load an Oracle table. In other systems such as TOAD...
3
by: wvmbark | last post by:
First time poster... I just found this forum and it appears there's plenty of people here that could make short work of problem that's been driving me absolutely bonkers for months. Every day we...
3
by: redbenn | last post by:
Hello, I am trying to create an excel macro, that when clicked... a specific cell will match a record in my database, and update certain fields in this record. The Excel file will have a cell...
17
by: DeZZar | last post by:
Hi all, I need to regularly backup my database as an Excel file and have been using the File Export option. Problem is I need anyone using the database to be able to do this easily - nopt...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.