473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Database Bloat on format Report

Hi,

I have a bloating database. Each time I "Print Preview" my Report, the database size increases by 25 MB.

The Report consists of 3 subreports, 1 imageControl and 2 textboxes. The image is not embedded, it's link is in the record of the report's source (query).

I do have some simple VBA code in the Report:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Compare Database
  3. Option Explicit
  4.  
  5. Private Sub VerticallyCenter(ctl As Control)
  6.     Dim lngHeight As Long
  7.     lngHeight = fTextHeight(ctl)
  8.     ' Rounding will result in a 1 to 2 pixel margin of error
  9.     ' of every control before it renders text.
  10.     ctl.TopMargin = ((ctl.Height - lngHeight) / 2)
  11. End Sub
  12.  
  13. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  14.     'Assign Label Values in Footer & Header
  15.     Dim lookDept As Variant
  16.     Dim strDept As Variant
  17.     Dim lookModel As Variant
  18.     Dim strModel As Variant
  19.     Dim lookVariantID As Variant
  20.     Dim strVariant As Variant
  21.  
  22.     lookDept = DLookup("DeptID", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  23.     strDept = DLookup("Department", "tblDepartments", "DeptID = " & lookDept & "")
  24.  
  25.     lookModel = DLookup("ModelID", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  26.     strModel = DLookup("Model", "tblModels", "ModelID = " & lookModel & "")
  27.  
  28.     lookVariantID = DLookup("VariantID", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  29.     strVariant = DLookup("Variant", "qryVariant", "VariantID = " & lookVariantID & "")
  30.  
  31.     Me.lblOperationName.Caption = DLookup("Description", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  32.     Me.lblModel.Caption = strModel
  33.     Me.txtOperation.Value = DLookup("Operation", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  34.     Me.lblVariant.Caption = strVariant
  35.  
  36.     Me.txtFooterOperation.Value = DLookup("Operation", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  37.     Me.lblFooterModel.Caption = strModel
  38.     Me.lblFooterOperation.Caption = "Final Quality Check"
  39.     Me.lblFooterVariant.Caption = strVariant
  40.  
  41.  
  42.  
  43. End Sub
  44.  
  45. Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
  46.  
  47.     ' Gathering data for Building Name String for Document
  48.  
  49.     Dim strDocCode As String
  50.     Dim strDocName As String
  51.     Dim strOperation As String
  52.     Dim strOperationDesc As String
  53.     Dim varRevisionNo As Variant
  54.     Dim lookDept As Variant
  55.     Dim strDept As String
  56.     Dim lookModel As Variant
  57.     Dim strModel As String
  58.     Dim strModelShort As String
  59.     Dim lookVariantID As Variant
  60.     Dim strVariant As String
  61.     Dim strDeptShort As String
  62.     Dim strRevShort As String
  63.  
  64.  
  65.     lookDept = DLookup("DeptID", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  66.     strDept = DLookup("Department", "tblDepartments", "DeptID = " & lookDept & "")
  67.     strDeptShort = Left(strDept, 1)
  68.  
  69.     lookModel = DLookup("ModelID", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  70.     strModel = DLookup("Model", "tblModels", "ModelID = " & lookModel & "")
  71.     strModelShort = DLookup("ModelAbbreviation", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  72.  
  73.     lookVariantID = DLookup("VariantID", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  74.     strVariant = DLookup("Variant", "qryVariant", "VariantID = " & lookVariantID & "")
  75.  
  76.     strOperation = DLookup("Operation", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  77.     strOperationDesc = DLookup("Description", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  78.  
  79.     varRevisionNo = DLookup("MaxofWIrevNo1", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  80.  
  81.  
  82.     If varRevisionNo > 99 Then
  83.         strRevShort = varRevisionNo
  84.         ElseIf varRevisionNo > 9 Then
  85.         strRevShort = "0" & varRevisionNo
  86.         ElseIf varRevisionNo < 10 Then
  87.         strRevShort = "0" & "0" & varRevisionNo
  88.     End If
  89.  
  90.  
  91.     ' Actual building of the String for the Document Name
  92.  
  93.     strDocCode = "W" & strDeptShort & "-" & strModelShort & "-" & strOperation & "-" & strRevShort
  94.     strDocName = strDocCode & " " & strOperationDesc
  95.  
  96.     Me.txtDocumentName.Value = strDocName
  97.  
  98. End Sub
  99.  
  100. Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
  101.     If Me.Page = 2 Then
  102.         Me.lblOperationName.Caption = "Safety Sheet"
  103.     Else
  104.         Me.lblOperationName.Caption = DLookup("Description", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  105.     End If
  106.     If Me.Page = 3 Then
  107.         Me.lblOperationName.Caption = "Entry Quality Check"
  108.     End If
  109. End Sub
  110.  
  111. Private Sub Report_Close()
  112.     DoCmd.OpenForm "MainForm", acNormal, "", "", , acNormal
  113. End Sub
  114.  
  115.  
  116. Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
  117.  
  118.     ' Gathering data for Building Name String for Document
  119.  
  120.     Dim strDocCode As String
  121.     Dim strDocName As String
  122.     Dim strOperation As String
  123.     Dim strOperationDesc As String
  124.     Dim varRevisionNo As Variant
  125.     Dim lookDept As Variant
  126.     Dim strDept As String
  127.     Dim lookModel As Variant
  128.     Dim strModel As String
  129.     Dim strModelShort As String
  130.     Dim lookVariantID As Variant
  131.     Dim strVariant As String
  132.     Dim strDeptShort As String
  133.     Dim strRevShort As String
  134.  
  135.  
  136.     lookDept = DLookup("DeptID", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  137.     strDept = DLookup("Department", "tblDepartments", "DeptID = " & lookDept & "")
  138.     strDeptShort = Left(strDept, 1)
  139.  
  140.     lookModel = DLookup("ModelID", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  141.     strModel = DLookup("Model", "tblModels", "ModelID = " & lookModel & "")
  142.     strModelShort = DLookup("ModelAbbreviation", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  143.  
  144.     lookVariantID = DLookup("VariantID", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  145.     strVariant = DLookup("Variant", "qryVariant", "VariantID = " & lookVariantID & "")
  146.  
  147.     strOperation = DLookup("Operation", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  148.     strOperationDesc = DLookup("Description", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  149.  
  150.     varRevisionNo = DLookup("MaxofWIrevNo1", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  151.  
  152.  
  153.     If varRevisionNo > 99 Then
  154.         strRevShort = varRevisionNo
  155.         ElseIf varRevisionNo > 9 Then
  156.         strRevShort = "0" & varRevisionNo
  157.         ElseIf varRevisionNo < 10 Then
  158.         strRevShort = "0" & "0" & varRevisionNo
  159.     End If
  160.  
  161.  
  162.     ' Actual building of the String for the Document Name
  163.  
  164.     strDocCode = "W" & strDeptShort & "-" & strModelShort & "-" & strOperation & "-" & strRevShort
  165.     strDocName = strDocCode & " " & strOperationDesc
  166.  
  167.     Me.txtDocName.Value = strDocName
  168.  
  169. End Sub
  170.  
  171. Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
  172.  
  173.     VerticallyCenter Me.lblApproved
  174.     VerticallyCenter Me.lblDocnameA
  175.     VerticallyCenter Me.lblOperationA
  176.     VerticallyCenter Me.lblOperationDescription
  177.     VerticallyCenter Me.lblPages
  178.     VerticallyCenter Me.lblRevdateA
  179.     VerticallyCenter Me.lblVariantA
  180.     VerticallyCenter Me.lblRevisionNo
  181.     VerticallyCenter Me.lblB
  182.     VerticallyCenter Me.lblC
  183.     VerticallyCenter Me.lblD
  184.     VerticallyCenter Me.lblE
  185.     VerticallyCenter Me.lblF
  186.     VerticallyCenter Me.lblG
  187.  
  188.     ' Gathering data for Building Name String for Document
  189.  
  190.     Dim strDocCode As String
  191.     Dim strDocName As String
  192.     Dim strOperation As String
  193.     Dim strOperationDesc As String
  194.     Dim varRevisionNo As Variant
  195.     Dim lookDept As Variant
  196.     Dim strDept As String
  197.     Dim lookModel As Variant
  198.     Dim strModel As String
  199.     Dim varColor As Variant
  200.     Dim strModelShort As String
  201.     Dim lookVariantID As Variant
  202.     Dim strVariant As String
  203.     Dim strDeptShort As String
  204.     Dim strRevShort As String
  205.     Dim strRevDate As String
  206.     Dim strRevDateLong As String
  207.     Dim strMachinePicture As String
  208.  
  209.     Dim EngInit As String
  210.     Dim PEDInit As String
  211.     Dim ForInit As String
  212.  
  213.     lookDept = DLookup("DeptID", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  214.     strDept = DLookup("Department", "tblDepartments", "DeptID = " & lookDept & "")
  215.     strDeptShort = Left(strDept, 1)
  216.  
  217.     lookModel = DLookup("ModelID", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  218.     strModel = DLookup("Model", "tblModels", "ModelID = " & lookModel & "")
  219.     varColor = DLookup("ColorCode", "tblModels", "ModelID = " & lookModel & "")
  220.     strModelShort = DLookup("ModelAbbreviation", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  221.  
  222.     lookVariantID = DLookup("VariantID", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  223.     strVariant = DLookup("Variant", "qryVariant", "VariantID = " & lookVariantID & "")
  224.  
  225.     strOperation = DLookup("Operation", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  226.     strOperationDesc = DLookup("Description", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  227.  
  228.     varRevisionNo = DLookup("MaxofWIrevNo1", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  229.     strRevDate = DLookup("WIrevDate", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  230.     strRevDateLong = Format(strRevDate, "Medium Date")
  231.  
  232.     strMachinePicture = DLookup("MachinePicture", "qryFilter", "MaxofWorkRevID = TempVars!WISelect")
  233.  
  234.     If varRevisionNo > 99 Then
  235.         strRevShort = varRevisionNo
  236.         ElseIf varRevisionNo > 9 Then
  237.         strRevShort = "0" & varRevisionNo
  238.         ElseIf varRevisionNo < 10 Then
  239.         strRevShort = "0" & "0" & varRevisionNo
  240.     End If
  241.  
  242.     EngInit = Nz(DLookup("EngInitial", "tblApprovals", "WorkRevID = Tempvars!WISelect"), "")
  243.     PEDInit = Nz(DLookup("PEDInitial", "tblApprovals", "WorkRevID = Tempvars!WISelect"), "")
  244.     ForInit = Nz(DLookup("ForInitial", "tblApprovals", "WorkRevID = Tempvars!WISelect"), "")
  245.  
  246.  
  247.     ' Actual building of the String for the Document Name
  248.  
  249.     strDocCode = "W" & strDeptShort & "-" & strModelShort & "-" & strOperation & "-" & strRevShort
  250.     strDocName = strDocCode & " " & strOperationDesc
  251.  
  252.  
  253.  
  254.  
  255.  
  256.     'Set Labels
  257.  
  258.     Me.lblDepartment.Caption = strDept
  259.     Me.lblDocnameA.Caption = strDocCode
  260.     Me.lblModelA.Caption = strModel
  261.     Me.lblVariantA.Caption = strVariant
  262.     Me.lblOperationA.Caption = strOperation
  263.     Me.lblOperationDescription.Caption = strOperationDesc
  264.     Me.lblRevdateA.Caption = strRevDateLong
  265.     Me.lblRevisionNo.Caption = varRevisionNo
  266.     Me.lblPages.Caption = Pages
  267.  
  268.     Me.lblEngineeringInitial.Caption = EngInit
  269.     Me.lblPEDInitial.Caption = PEDInit
  270.     Me.lblForemanInitial.Caption = ForInit
  271.  
  272.     Me.chkEng.Value = DLookup("EngApp", "tblApprovals", "WorkRevID = Tempvars!WISelect")
  273.     Me.chkPED.Value = DLookup("PEDApp", "tblApprovals", "WorkRevID = Tempvars!WISelect")
  274.     Me.chkFor.Value = DLookup("ForApp", "tblApprovals", "WorkRevID = Tempvars!WISelect")
  275.  
  276.     Me.Caption = strDocName
  277.     Me.boxColor.BackColor = varColor
  278.     Me.ImageMachine.Picture = strMachinePicture
  279.  
  280.  
  281. End Sub
  282.  
  283.  
I've already tried Compact & Repair several times. The database is reduced by 1-2 kb after each compact.

Because each record of my Report contains a Image, the formatting takes several seconds. Could it be that Acces saves the images in the database in sort of Temporary File? Or is there another problem?

In the attachment a screenshot of the Printed View of the Report is shown.
Attached Images
File Type: jpg Example Instruction.jpg (70.8 KB, 179 views)
Feb 26 '15 #1
5 1185
Found it! I had an embedded Picture in my Report's Header. It happened to be a high Quality picture (14 MB) of a product. Everytime I've viewed my report, Acces made a backup of that Image and put it in a hidden table "MSysResources". I've deleted the 123 duplicates and now my database is a healthy 8 MB again instead of the 1.5 GB.

For more info:

https://misterslimm.wordpress.com/20...d-image-cache/
Feb 26 '15 #2
Hmm now I'm trying to write a SQL DELETE statement to delete the last two records from the MSysResources Table. This is the code I have:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Close()
  2.  
  3.     'Clear the last two entries from the hidden MSysResources table to avoid Database Bloating.
  4.  
  5.     Dim SQL1 As String
  6.     Dim MsysMax1 As Integer
  7.     Dim MsysMax2 As Integer
  8.  
  9.     MsysMax1 = DMax("Id", "MSysResources")
  10.     MsysMax2 = MsysMax1 - 1
  11.  
  12.     SQL1 = "DELETE FROM MSysResources" & _
  13.             "WHERE Id = MsysMax1" & _ 
  14.             "AND Id = MsysMax2;"
  15.  
  16.     DoCmd.SetWarnings False
  17.     DoCmd.RunSQL SQL1
  18.     DoCmd.SetWarnings True
  19.  
  20.     DoCmd.OpenForm "MainForm", acNormal, "", "", , acNormal
  21. End Sub
Everytime I get an Error in the "FROM" clause but to me the SQL seems alright.

Is it possible that you can't use SQL on a hidden (System) table?
Feb 26 '15 #3
Rabbit
12,516 Expert Mod 8TB
That's not it, you've formatted your SQL incorrectly. This is what the SQL engine is seeing:
Expand|Select|Wrap|Line Numbers
  1. DELETE FROM MSysResourcesWHERE Id = MsysMax1AND Id = MsysMax2;
Whereas what you want it to see is something like this:
Expand|Select|Wrap|Line Numbers
  1. DELETE FROM MSysResources WHERE Id = 10 OR Id = 9;
Feb 26 '15 #4
MsysMax1 is an Integer, it's the maximum record Id from table MSysResources. So for instance if I have a total of 70 records, MsysMax1 = 70. If I run the code and hover over MsysMax1, the value 70 appears. So that seems to be working.

I've tried this:

Expand|Select|Wrap|Line Numbers
  1.     SQL1 = "DELETE FROM MSysResources" & _
  2.           "WHERE Id = " & MsysMax1 & ";"
and also this:

Expand|Select|Wrap|Line Numbers
  1.     SQL1 = "DELETE FROM MSysResources" & _
  2.           "WHERE Id = 70;"
Still got the "Syntax error in FROM clause".
Feb 27 '15 #5
Solved it! There was no space between " and WHERE so my SQL would look like: DELETE FROM MSysResourcesWHERE Id = 70.

This is the final working code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Close()
  2.  
  3.     'Clear the last two entries from the hidden MSysResources table to avoid Database Bloating.
  4.  
  5.     Dim SQL1 As String
  6.     Dim SQL2 As String
  7.     Dim MsysMax1 As Integer
  8.     Dim MsysMax2 As Integer
  9.  
  10.     MsysMax1 = DMax("Id", "MSysResources")
  11.     MsysMax2 = MsysMax1 - 1
  12.  
  13.     SQL1 = "DELETE FROM MSysResources" & _
  14.            " WHERE Id = " & MsysMax1 & ";"
  15.  
  16.     SQL2 = "DELETE FROM MSysResources" & _
  17.            " WHERE Id = " & MsysMax2 & ";"
  18.  
  19.     DoCmd.SetWarnings False
  20.     DoCmd.RunSQL SQL1
  21.     DoCmd.RunSQL SQL2
  22.     DoCmd.SetWarnings True
  23.  
  24.     DoCmd.OpenForm "MainForm", acNormal, "", "", , acNormal
  25.  
  26. End Sub
This method isn't foolproof to clear the last records in the MSysResources table but it works for mine. Now my database doesn't bloat any more!
Feb 27 '15 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: Michael Malinsky | last post by:
I'm attempting to create a database which will take information from one (perhaps two) tables and utilize that information to return queries to a report designed in Excel. The general idea I...
1
by: fanor | last post by:
Hi guys, How can I change at runtime the database for a report?? I need to do this, because my aplication would be installed in any directory. TIA
7
by: Danny J. Lesandrini | last post by:
I know this has been discussed before, as I've seen the Google posts, but they all leave me with an unanswered question: Does my DAO code executed in the front end cause the back end to bloat?...
5
by: MLH | last post by:
I've read a number of posts over the years that dealt with the issue of database bloat. I'm wondering if anyone has determined exactly what information comprises the bloat when it does occur. Has...
2
by: fatboy | last post by:
I'm trying to change the database and server on a report that was created using integrated security e.g. report was created pointing to the server 'testserver' and database 'testdb' and at runtime...
5
by: Sport Girl | last post by:
Hi everybody. I am new in PERL language and working in it since little hours, actually i am still a trainee and i need help please. In fact, i need a script in PERL that enables me to retrieve...
6
by: hemak2006 | last post by:
hai... can anyone plz tell me that how to access image from database to data report...
6
by: Randy Shore | last post by:
I have a shared Access mdb that was originally written in A2000. The database is large, around 40 tables, 40 forms (many with multiple sub-forms), and 100s of reports. The database is not split,...
2
by: hmznzr | last post by:
i am using b.net 2005. i am generating a crystal report. but when i work in a different computer i have to set the location of the database of the report before i generate. is their any dynamic way...
1
by: oconrl4 | last post by:
I need to know how to expand the number of rows to import into an access database from a report. The limit is currently set to 100 rows. The access database is 2003. I am new to access. The users...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.