How to Delete Windows Files from Access 2000

We have a Folder in Windows XP that we use to hold .pdf reports for attachment to emails and fax out purposes. (put there by Stephen Lebans Code)

As these are Temporary Files, it would be good if they can be deleted from within Access.

Is there a way to do this by VBA or other method??


Post your answer or comment

comments powered by Disqus
Hi there,
I need to export the table from access 2003 into .prn file.
By some reasons we use that kind of files for uploading into anther DB in AS400 (which is stupid, but we can't change that).
I can't find the option in Acess to export as .prn
I can do that from excel but amount of lines is much bigger than 100000 so I need to do it from Access directly.

I tried to export as .txt and rename into prn, but it dosen't work for the upload as the file structure is different.

The upload works only if there is sertain width between the data.

May be there is a way of converting the txt file into prn....
Just a tought...

Thanks to everybody who read this.

Hi,

I'm trying to delete all the files from a folder once I've copied it to another location. Now stuck at trying to find a code to do the deletion. Tried deleteFile function, also object.delete,

something like this:


	Code:
	dim myObject as object
 
set myObject=me.path 'path contains the pathway to the file I want to delte
 
myObject.delete 'doesn't work the way the access help said it's supposed to

Help?

Hi,

I have some vba code which copies the current database to an archive directory and zips it up and renames it with a date/time stamp.

This archiving code is initiated on a daily basis therefore as you can imagine the number of archive files will soon add up. I want to be able to add code so that any old archive files, say 20 days old, is deleted, and therefore keeping the number of files archived to a minimum.

Is there any access code which will check the date/time of when the file was created so that I can check and see how old it is in order to determine whether to delete the file or not?

Cheers.

Hi All,

I'm not able to run SQL queries from Access 2003.

I've coneected to MSDE (which is on the same machine I'm working on). I've selected a Database 'TastDB'. Now I want to run a script (containing 'Create Table') on TestDB from Access.

How can it be done? I've searched this forum as well as the Access help but couldn't do this.

I found following steps, but couln't found step 4 mentioned below (i.e. On the Query menu, point to SQL Specific). I don't see SQL Specific button there:In the Database window (Database window: The window that appears when you open an Access database or an Access project. It displays shortcuts for creating new database objects and opening existing objects.), click Queries under Objects, and then click New on the Database window toolbar. In the New Query dialog box, click Design View, and then click OK. Without adding tables or queries, click Close in the Show Table dialog box. On the Query menu, point to SQL Specific, and then click Data Definition. Enter the SQL statement for your data-definition query. Each data-definition query consists of just one data-definition statement. Can anybody help???

I am running an export to an excel file from access and after the export I need to open the file and apply formatting to it (format height/width of cells, do an auto filter, etc.)

I'm not sure how to get Access to open the file so that I can work with it. I know all the code for formatting the excel file, all I'm trying to figure out is how to get Access to interface.

I had found another thread here and this code was supposed to work but is erroring out with a user-defined type not defined error. Anyway here is just that code, minus all the excel macro stuff.


Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook

Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbook.Open("c:rmexport.xls")

Any help would be appreciated.

BACKGROUND:
I have an external batch file that is called by MS Access. This backup file makes a copy of the calling MS Access file every time the database is opened.

GOAL:
What I want to do is now modify the batch file to delete old backups.

NAMING CONVENTION:
All bacup files are uncompressed and follow the naming convention below

YYYY-MM-DD_databaseName.mdb.bak

Any thoughts on how to delete all files where the YYYY-MM-DD is more than 7 days old?
________
F50

I want to delete a file and send it to to the recycle bin. Currently I seem to be able to kill/delete a file but the files do not go to the recycle bin and so can I not recover them if I make an error.

Thank you in advance.

smiler44

Hi,

I have many files which also contains different sheets to import from Excel into Access database. I have written a macro below to import the file into Access.


	Code:
	Private Sub Import_Click()

Dim filenames As String
Dim sheet_names As String

filenames = Combo4.Value
sheet_names = Combo6.Value

    DoCmd.SetWarnings False
    DoCmd.TransferSpreadsheet acImport, 8, "filenames", "H:Project3filenames.xls", False, "sheet_names!A10:H100"
    ' delete table data
    DoCmd.OpenQuery "filenames Query", acNormal, acEdit
    ' import data
    DoCmd.TransferSpreadsheet acImport, 8, "filenames", "H:Project3filenames.xls", False, "sheet_names!A10:H100"
    ' show data
    DoCmd.OpenTable "filenames", acNormal, acReadOnly


End Sub


With reference to the code,
The combo4 (which is the different file names) refers to the drop down menu of a form in Access.
The combo6 (which is the different sheet names) refers to the drop down menu of the same form in Access.
From the drop down menus, I can choose filenames like fruits and sheet names like apple, banana. So when I click the import button, it will import the particular file that is chosen and show the table.

The problem is the directory (H:Project3filenames.xls) and the sheet names cannot be changed. For instance if I choose fruits from the drop down menu, then the directory shd be (H:Project3fruits.xls) and if I choose apple as the sheet name, it shd be “apple!A10:H100”.

How can I have 2 user-input values (from the drop down menus which contains 2 lists of filenames and sheet names) so that whenever I click the import button, it will import the file that the user has chosen from Excel into Access?

How can I delete a file from access that is on my desktop? When I use the deleteobject command access assumes that I want to delete an access object (not a bad assumption, just not what I want right now). Thank you. Marie

Anyone knows how to export data structures from MS Access 2000? I want to export field name, field type, field size, remarks from the structure. No records are required! Does it possible? Please help!

Wilson

Hi,

Using code in Access how is it possible to delete an Excel File.

Have tried the Kill statement but cannot get it to work.

Any advice greatfully accepted!!!

I have an Access database that has multiple linked Excel spreadsheets. I have queries which append the data from the Excel files to an Access table.

After the queries run I need to delete the data from the excel files except for the first row which contains the column headers.

How can be delete these records from Access?

Thanks,
Steve

How to Import Txt file that dont have delimiters (Seprators) in Access DB.
Actually iget this file from server...and every time i have to do it manaually.
I need to automate this....please help
thanks

I finally figured out how to append to my XML file using the XML DOM Reference.
We use an application that reads an XML file and uploads the data into Sage Line 50.
We are planning to carry out a series of order processing using Access, to stop a lot of the errors and solve some of the speed issues that we encounter when users are using Sage 50.
My problem is that the xml file would need to be loaded by each user onto memory so that they can append to it.
I can see already a series of problems there:
-Would they lock each other out when trying to load the document?
-Would they overwrite the data when both users are appending to the file?
-How long will the file take to load and find the nodes if many orders are saved within the file?

Any ideas?
To avoid loading times of the reading of the tree nodes I thought of writting to a log text file and then append the data from the log file into the main xml document.

Which leaves me with two worries, of the users writting to the log files at the same time, and how could I automate from Access to read each log file at a certain period of time and append it to the xml file?

Hi everyone,

My company is looking to upgrade the backend of our programs from Access 2000 to SQL Server 2005 Express. There are some issues we need to address with this before we can begin. We have 300 - 400 clients who use our product. The biggest issue we have is this. We have 10 - 15 VB applications each with its own Access database. Some access multiple databases to run. We are not goign to be able to upgrade all our programs instantaneously so I need a way to have an SQL Server running and let some applications access it directly. I also need some programs to access the Access 2000 databases to update information then i need that information to instantly be sent to the SQL Server to update its information also. I have no idea how i can achieve this goal. Any help you could give me would be greatly appreciated.

Thanks

Dave

Hi,

I need to open an excel *.xlsx file from Access 2010 using a macro or VBA but can't get any of the examples on various forums to work. Please help.

Thanks in advance.

Stu

Hi Forum,

Just downloaded Lebans sample database and two dlls.

Files are: A2000SnapshotToPDFver785.mdb
dynapf.dll
StrStorage.dll

My understanding is that the two .dll files must be copied to the same folder where our database is stored but... Front End or Back End ??

The code itself is more the one Sub.
These are not Public so does that mean they must be repeated at every instance of a command Button to create a Report (that we want as a .pdf)

Anyone using Lebans on access 2000?

Thanks, Bill

I've been trying to figure out how to extract extended file properties in Access. Apparently the FileSystem object only returns the standard set of file properties, such as the name of the file. Microsoft has a description of how to use VBA to retrieve extended file properties, such as the author of a file.

Additionally, stngman posted in UtterAccess an approach on how to retrieve extended file properties in Access.

The approach used by stngman, while it works, appears to require a lot of looping. I was hoping to avoid this looping since my program is already looping through the files. Alas, all that I have been able to get is the name of the extended property NOT the actual value. See the line of code in bold red.

Based on the Microsoft table, the file property with the value of "0" should return the actual name of the file, but all I get is the the name of the field which is "name". Any Thoughts?


	Code:
	Public Sub Create_File_List(InputPath As String)
    Dim CopyMP3RS As DAO.Recordset
    Dim Fso As Object
    Dim Fldr As Object
    Dim SubFldr As Object
    Dim F As Object
    Rem New Shell.Application Code Below -----------------------------------
    Dim objShell As Object
    Dim ojbFolder As Object   
    Set objShell = CreateObject("Shell.Application")
    Rem Rem New Code Above --------------------------------
    Set Fso = CreateObject("scripting.filesystemobject")
    Set Fldr = Fso.GetFolder(InputPath)
    Set CopyMP3RS = CurrentDb.OpenRecordset("SELECT * FROM tblMP3_FileList", dbOpenDynaset)
        For Each F In Fldr.Files
        Debug.Print "Name"; Fldr.Name, "type; "; Fldr.Type, "Path: "; Fldr.Path
        Set objFolder = objShell.NameSpace(Fldr.Path & "")       
        If Right(F.Name, 4) = ".mp3" Then
            CopyMP3RS.AddNew
                Debug.Print "File: "; F.Name, objFolder.GetDetailsOf(F.Name, 0)
                CopyMP3RS!FileLocation = F.Path
                CopyMP3RS!FileName = F.Name
                CopyMP3RS!FileSize = F.Size
            CopyMP3RS.Update
            End If
        Next F
    Rem ---------------------------------------
    For Each Fldr In Fldr.SubFolders
         Call Create_File_List(Fldr.Path)
    Next Fldr
End Sub



Xml output from access 2000
hi,

I need to output a table to an xml file. good old google has returned the following:-
Code:

	Code:
	Private Sub Form_Open(Cancel As Integer)


  Dim sXMLPath As String
  Const cOverWrite As Integer = 1
  sXMLPath = "c:technologies.xml"
  
  ' ExportXML ObjectType, DataSource, DataTarget
  ExportXML acExportTable, "technologies", sXMLPath
  
End Sub

Howevever this falls over with Compile error: syntax error on the following line:-
ExportXML acExportTable , "technologies", sXMLPath


Any thoughts greatly appreciated.

I need to load WAV files from a directory into an Ms Access ' 97 Database through VB/VBA. I have created tables with OLE Objects data type. Thank you in advance for the reply.

Erm Hi everyone I'm new.

Sorry about the rather striking title, but I have an assignment with the deadline tomorrow and I need to find out how to perform numeric calculations in access with different fields (i.e. adding numbers, minusing etc.)

Well, I had to make a project at school for my GNVQ ICT, I chose the advanced sales database, since its a project we have to add in our own features and find out about them ourselves. Well I thought I'd create one for my company inside school, I wanted to create a database that would print invoices and monitor all the resources we have. The project has to be in on monday!

However all was going well until I came upon a slight problem, I'm not sure how to do calculations in Microsoft Access!

Well basically this is what I'm aiming at, its nothing too complicated really.

I have a table called RESOURCES which keeps track of all of the stock the company has (e.g. how much paper, how many mugs, tshirts etc.). I want the database to be able to automatically take 1 away from the selected resource when a form is used to file a new order.

E.g.

I have a form asking me the details of the design, In the resources table I have set the quantity of mugs as 100, i.e. I have 100 mugs in stock and available.

I use the form and tell the database that I am making a design which will use 1 mug.

The database then goes to the resource table and takes 1 away from the available stock of mugs making the total mugs available 99.

I then the database to be able to do this automatically, when a checkbox is ticked, when the form is submitted I want it to see which text boxes are ticked and take the correct consequent resources from the RESOURCE table.

I have Access 2003, I have attached the file incase anyone needs it, note that the Forms have NOT been made only the resource, customers and orders tables have been created.

If someone could tell me how to do this I'd be extremely greatful, this is very URGENT I have to hand in the project on Monday!!!

I know I'm asking alot but I'd be really really greatful if someone could help me out!!!

Hello once more. I'll be short, you can be this short too.

Is there a way to open/run an Access 2003 Database from Access 2000?

I've searched, and couldn't come up with a solution for this. Let me know if you can find a thread..

I've linked a dbase XL file into Access. When a user deletes the record in Access, it is of course deleted in the dbase XL file...Only (Just as in Access) the record is only marked for deletion... How do I compact the dbase file? (Or, as dbase users call it...How do I "pack" the file from Access?)

Thanks,

Andrew

I have a table of records which have duplicate values in a certain column. e.g


	Code:
	ID      Name       Colour    Rate
1        John       Black       8
2        Peter      Black       9
3        Anne       Blue        8
4        Polly      Yellow      8
5        Serah      Green       9
6        Gary       Yellow      9

What I would like to do is keep unique Colour values only. So in the above example, there must be only one person who has Black, and only one person who has Yellow. I want the person that is removed to be the one who has the higher rate. So those with 9 will be deleted.

How can I do this in Access via SQL?


Not finding an answer? Try a Google search.