0% found this document useful (0 votes)
3 views

NEW UPDATE ACCESS

The document contains several VBA subroutines and functions for file management, including renaming files, saving a database with a backup, opening an Access database, and deleting a backup file. It demonstrates how to use the FileSystemObject to handle file operations and manage Access databases programmatically. The code is structured to perform specific tasks related to a database located in a designated directory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

NEW UPDATE ACCESS

The document contains several VBA subroutines and functions for file management, including renaming files, saving a database with a backup, opening an Access database, and deleting a backup file. It demonstrates how to use the FileSystemObject to handle file operations and manage Access databases programmatically. The code is structured to perform specific tasks related to a database located in a designated directory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sub RenameFile()

Name "C:\Users\sumit\Downloads\Old.xlsx" As "C:\Users\sumit\Downloads\New.xlsx"


End Sub

Sub RenameFile()
Dim oldName As String
Dim newName As String

oldName = "D:\Data Kerjaan\Lap Harian\01. UPDATE DATA PEMBIAYAAN App.accdb"


newName = "D:\Data Kerjaan\Lap Harian\01. UPDATE DATA PEMBIAYAAN App -
BackUp.accdb"

Name oldName As newName


End Sub

Public Function SaveAsFile()


Dim fso As Object
Dim strOldPath As String, strNewPath As String, strTempPath As String, strFileSize
As String
Dim newlength As Long

Set fso = CreateObject("Scripting.FileSystemObject")

strOldPath = CurrentDb.Name
strTempPath = ("D:\Data Kerjaan\Lap Harian\01. UPDATE DATA PEMBIAYAAN App -
TEMP.accdb")

strNewPath = ("D:\Data Kerjaan\Lap Harian\01. UPDATE DATA PEMBIAYAAN App.accdb")

'copy database to a temp file


fso.CopyFile strOldPath, strTempPath
Set fso = Nothing

strNewPath = ("D:\Data Kerjaan\Lap Harian\01. UPDATE DATA PEMBIAYAAN App.accdb")

'compact the temp file


DBEngine.CompactDatabase strTempPath, strNewPath

'delete the tempfile


Kill strTempPath

DoEvents
End Function

Public Function OpenFile()


Static acc As Access.Application
Dim db As DAO.Database
Dim strDbName As String

strDbName = "D:\Data Kerjaan\Lap Harian\01. UPDATE DATA PEMBIAYAAN App.accdb"


Set acc = New Access.Application
acc.Visible = True
Set db = acc.DBEngine.OpenDatabase(strDbName, False, False)
acc.OpenCurrentDatabase strDbName, vbMaximizedFocus
db.Close
Set db = Nothing
DoCmd.Quit
End Function

Public Function DeleteFile()


Dim fs As Object

Set fs = CreateObject("Scripting.FileSystemObject")
Const workFolder As String = "D:\Data Kerjaan\Lap Harian\01. UPDATE DATA PEMBIAYAAN
App - BackUp.accdb"

If fs.FileExists(workFolder) Then
Kill "D:\Data Kerjaan\Lap Harian\01. UPDATE DATA PEMBIAYAAN App -
BackUp.accdb"
End If
End Function

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy