Can anyone tell me if this is possible and if so How? (1 Viewer)

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 12:35
Joined
Sep 12, 2006
Messages
15,614
it's easy enough to look up the size of a backend.
This sort of thing will give you the name of the backend, and its size in Mb, and the name and size of your front end

Code:
Sub DBS_sizes()

Dim db As Database
Dim tdf As TableDef
Dim fname As String
Dim fname2 As String
Dim fsize As Long
Dim fsize2 As Long

Set db = CurrentDb
Set tdf = db.TableDefs("known linked table")

fname = Mid(tdf.Connect, 11)
fname2 = CurrentProject.fullName

fsize = FileLen(fname)
fsize2 = FileLen(fname2)

MsgBox "Back End: " & fname & vbCrLf & _
    "Size: " & Fix(fsize / 1024 / 1024) & "Mb" & vbCrLf & vbCrLf & _
    "Front End: " & fname2 & vbCrLf & _
    "Size: " & Fix(fsize2 / 1024 / 1024) & "Mb"

End Sub

Edit. I didn't realise this had apparently been resolved satisfactorily already.
 
Last edited:

rshaw

New member
Local time
Today, 06:35
Joined
Feb 10, 2020
Messages
21
Ok, here is a version with one text box to show the file size and a textbox for the message. If that still isn't what you wanted and maybe you were looking for a messagebox instead, then you can change the textboxcode to a messagebox. I hardcoded the filename and removed the space as I assume that was a typo. So if the name is not correct, when you open the form there will be an error message. The new form is called frmFileSizeHardCodE
 

rshaw

New member
Local time
Today, 06:35
Joined
Feb 10, 2020
Messages
21
Ok, here is a version with one text box to show the file size and a textbox for the message. If that still isn't what you wanted and maybe you were looking for a messagebox instead, then you can change the textboxcode to a messagebox. I hardcoded the filename and removed the space as I assume that was a typo. So if the name is not correct, when you open the form there will be an error message. The new form is called frmFileSizeHardCode
Again thanks so much for taking the time to help with this. I tried your code while it works in the example you sent me as it shows the size of that database that i need it to show. I cant seem to make it work on my end. I know it is something i am doing or not doing that is keeping it from working.
What i did was added an unbound text box highlighted it and went to the code window where i added your code. I wasnt sure about the module so i added it as well. from looking at it can you tell me what is wrong? the only thing i can think of is that i made a self-executable file out of that database to keep other users from changing the structure. But i have the unconverted version as well and cant seem to get your code to do what i want.
 

Attachments

  • Capture.PNG
    Capture.PNG
    1.2 KB · Views: 56
  • Capture2.PNG
    Capture2.PNG
    84.4 KB · Views: 60

rshaw

New member
Local time
Today, 06:35
Joined
Feb 10, 2020
Messages
21
Ok, here is a version with one text box to show the file size and a textbox for the message. If that still isn't what you wanted and maybe you were looking for a messagebox instead, then you can change the textboxcode to a messagebox. I hardcoded the filename and removed the space as I assume that was a typo. So if the name is not correct, when you open the form there will be an error message. The new form is called frmFileSizeHardCode
Oh maybe I figured out the issue. since your form name is frmFileSizeHardCode and my form is frmMainMenu could that be why its not working?
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:35
Joined
Sep 21, 2011
Messages
14,051
You have to change the names to match your db? :(
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:35
Joined
May 7, 2009
Messages
19,175
another version
 

Attachments

  • databaseSize.accdb
    424 KB · Views: 83

Users who are viewing this thread

Top Bottom