Get Database Size?

W

Warren

Hi all,

I want to jazz up my open screen on my access application.

Do anyone know of a way or a function (built-in or otherwise) that will
allow me to get and display my database's current size on a form?

Thanks in advance!


Warren
 
R

RoyVidar

Hi all,
I want to jazz up my open screen on my access application.

Do anyone know of a way or a function (built-in or otherwise) that
will allow me to get and display my database's current size on a
form?

Thanks in advance!


Warren

I suppose you could use

=FileLen(CurrentProject.Fullname)

which should also work directly in the controlsource of a control.
 
G

Graham R Seach

Warren,

In addition to Roy's good advice, you can use the StrFormatByteSize API to
format the value returned by FileLen(CurrentProject.Fullname) so it's a bit
more meaningful. So if FileLen(CurrentProject.Fullname) returns, say 3416064
(bytes), the following function will return "3.25 MB".

Private Declare Function StrFormatByteSize Lib "shlwapi" _
Alias "StrFormatByteSizeA" (ByVal dw As Long, _
ByVal pszBuf As String, ByVal cchBuf As Long) As Long

Public Function GetFormattedFileSize(ByVal lSize As Long) As String
Dim strOut As String

strOut = Space(64)

Call StrFormatByteSize(lSize, strOut, Len(strOut) - 1)
GetFormattedFileSize = Trim(strOut)
End Function


Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Top