By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,376 Members | 3,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,376 IT Pros & Developers. It's quick & easy.

Checking Available Disk Space.

P: n/a
Hello Everyone,

I've been searching for a few hours on how to check the available disk
space (on a Flash disk actually) from within MS-Access.

Basically, I want to ensure there is adequate room on the Flash drive
before a Backup is attempted.

I've been trying to get Doug's code working within Access 2007 (and
Vista x64), but it doesn't seem to work for me. I pasted this into a
Module by itself, but calling it just gives Nothing. No error, no
return values.

I saw a value post about using fs.availablespace but again, was
unable to get it working.

Any suggestions would be appreciated. Thank you very much!

-- Code below --


Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" _
(ByVal lpcurRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long

Sub FreeBytes(NetworkShare As String)

Dim curBytesFreeToCaller As Currency
Dim curTotalBytes As Currency
Dim curTotalFreeBytes As Currency

Call GetDiskFreeSpaceEx(NetworkShare, _
curBytesFreeToCaller, _
curTotalBytes, _
curTotalFreeBytes)

'show the results, multiplying the returned
'value by 10000 to adjust for the 4 decimal
'places that the currency data type returns.
Debug.Print " Total Number Of Bytes:", _
Format$(curTotalBytes * 10000, "###,###,###,##0") & " bytes"

Debug.Print " Total Free Bytes:", _
Format$(curTotalFreeBytes * 10000, "###,###,###,##0") & "
bytes"

Debug.Print " Free Bytes Available:", _
Format$(curBytesFreeToCaller * 10000, "###,###,###,##0") & "
bytes"

Debug.Print " Total Space Used :", Format$((curTotalBytes -
curTotalFreeBytes) * 10000, "###,###,###,##0") & " bytes"

End Sub
Jan 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.