Results 1 to 11 of 11
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts

    database size (2003)

    Is there an easy way in VB to determine the size of your database? I am approaching 1.3 gigs and want a message to pop up when the database is opened stating what size it is. Is this possible?

    Thanks
    Kevin
    Kevin

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: database size (2003)

    CreateObject("Scripting.FileSystemObject").GetFile (CurrentProject.FullName).Size will return the file size in bytes. Divide by 2^10 to get the size in KB, by 2^20 to get the size in MB, or by 2^30 to get the size in GB.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: database size (2003)

    Thanks Hans,

    Sounds like this needs to be in a module with a call to that function from the log on form. Do i need to provide the "Full PathName", or just the full name with the ".mdb" Extention?

    Thanks
    Kevin
    Kevin

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: database size (2003)

    CurrentProject.FullName returns the full path and filename of the database.

    You can use it in the On Load event of the startup form of the database, like this:
    <code>
    Private Sub Form_Load()
    MsgBox "The current size of the database is " & _
    CreateObject("Scripting.FileSystemObject"). _
    GetFile(CurrentProject.FullName).Size / 2^20 & " MB", vbInformation
    End Sub
    </code>
    If you don't have a startup form, you can create a function in a standard module:
    <code>
    Public Function ShowSize()
    MsgBox "The current size of the database is " & _
    CreateObject("Scripting.FileSystemObject"). _
    GetFile(CurrentProject.FullName).Size / 2^20& " MB", vbInformation
    End Function
    </code>
    Create a macro with a RunCode action with ShowSize() as argument. Name this macro AutoExec. It will be executed automatically when the database is opened.

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: database size (2003)

    thank you !
    Kevin

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New England (Connecticut)
    Posts
    200
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: database size (2003)

    Hans,

    Just out of curiosity, When there is a Front End / Back End set up and all the tables in the BE are linked to the FE, does this impact any size limitations such as the 2 gig limit on the database? In other words, is the actual database size the combined size of the FE and BE, (because of the linked tables)?

    thanks
    Kevin
    Kevin

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: database size (2003)

    CurrentProject.FullName gets the front end

    in my case functions GetFile(fngetlinkedpath() & _
    GetLinkedTableDBName("tsysDBVersionsRemote") gets the backend

    HTH, John

    <pre>Public Function ShowSizeFrontEndMB()
    MsgBox "The current size of the database is " & _
    CreateObject("Scripting.FileSystemObject"). _
    GetFile(CurrentProject.FullName).Size / 2 ^ 20 & " MB", vbInformation
    End Function
    </pre>


    <pre>Public Function ShowSizeBackEndMB()
    MsgBox "The current size of the database is " & _
    CreateObject("Scripting.FileSystemObject"). _
    GetFile(fngetlinkedpath() & _
    GetLinkedTableDBName("tsysDBVersionsRemote")).Size / 2 ^ 20 & " MB", vbInformation
    End Function
    </pre>


  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: database size (2003)

    No, since the data are not actually stored in the frontend, they don't count towards the database size. The linked tables take up only a little bit of space in the frontend database.

  9. #9
    4 Star Lounger
    Join Date
    Sep 2004
    Location
    Sacramento, California, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: database size (2003)

    Would be interesting to have backend size. Searching the forum for this function fngetlinkedpath() to get the backend path and I was not able to find it. Could you post code?
    Carla

  10. #10
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: database size (2003)

    Hi Carla

    I think these functions came from the lounge

    TsysDBVersionsRemote is a table that is in all my BE

  11. #11
    4 Star Lounger
    Join Date
    Sep 2004
    Location
    Sacramento, California, USA
    Posts
    432
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: database size (2003)

    Thank you for the function. I seem to recall seeing them in the lounge, but could not find them with any of the keywords I wued.

    Carla

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •