473,468 Members | 1,371 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Exporting data - Check to see if file exists

47 New Member
Hello Everyone,

I would like to export data from a form in access to a static location on the user's hard drive with the same name everytime. The problem with this is that when you use the transfertext function in vbscript it does not ask if you would like to overwrite the old file it just does.

Is there a way to check if a file already exists before exporting and overwriting? If so how? I would like the user to see a messagebox asking if they want to overwrite or cancel.

Thanks!
Jul 24 '07 #1
2 3862
Rabbit
12,516 Recognized Expert Moderator MVP
Here's a code snippet of what I use for that very purpose.

Expand|Select|Wrap|Line Numbers
  1.         If Dir(path) <> "" Then
  2.             If MsgBox(path & " already exists." & Chr(13) & "Do you wish to overwrite the file?", vbYesNo) = vbYes Then
  3.                 Kill path
  4.             Else
  5.                 Exit Sub
  6.             End If
  7.         End If
  8.  
Jul 24 '07 #2
FishVal
2,653 Recognized Expert Specialist
Hello Everyone,

I would like to export data from a form in access to a static location on the user's hard drive with the same name everytime. The problem with this is that when you use the transfertext function in vbscript it does not ask if you would like to overwrite the old file it just does.

Is there a way to check if a file already exists before exporting and overwriting? If so how? I would like the user to see a messagebox asking if they want to overwrite or cancel.

Thanks!
Hi!

This maybe some simple function like the following one.
Expand|Select|Wrap|Line Numbers
  1. Public Function DoesFileExist(strPath As String) As Boolean
  2.  
  3.     On Error GoTo Failed
  4.  
  5.     FileLen strPath
  6.     DoesFileExist = True
  7.     Exit Function
  8.  
  9. Failed:
  10.     DoesFileExist = False
  11.  
  12. End Function
  13.  
Jul 24 '07 #3

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

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
3
by: Chris | last post by:
Could someone please provide me an effective means of exporting data from a data set (or data grid) to Excel?
12
by: alessia | last post by:
hi, I have a query that visualizes me, according to some criterions from me inserted, name , Surname , Address , phone ok.. Now, through a button, positioned in a Form, I have to only export...
1
by: nunYa | last post by:
I am trying to use the DoCmd.TransferText method to export an access table to a Tab Delimited Text File. I have put the code behind the onclick event of a button and keep getting the error...
2
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform...
3
by: David P. Donahue | last post by:
I'm re-writing an application in C# that was originally written in Delphi 7. The heart of the application is a DataSet displayed in a DataGrid. One of the main functions of the previous...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.