Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compacting with code multiple times

Status
Not open for further replies.
May 5, 2000
168
US
I have a long procedure that needs to be compacted multiple times.&nbsp;&nbsp;I have used the function in FAQ's using the keycode.&nbsp;&nbsp;If I prune down my code the compact works the first time, but with this long procedure it seems to skip right over the call to the function.&nbsp;&nbsp;I tried using the function in a separate module and then putting it in the same module.&nbsp;&nbsp;Anyone know what's going on here.&nbsp;&nbsp;The code is long but here it is.<br><br>=======<br><br>Option Compare Database<br>Option Explicit<br><br><br>Private Sub RunUpdate_Click()<br>&nbsp;DoCmd.Hourglass True<br>&nbsp;DoCmd.SetWarnings False<br><br>&nbsp;If ObjectExists(acTable, &quot;PROJECT&quot;) Then DoCmd.DeleteObject acTable, &quot;PROJECT&quot;<br>&nbsp;If ObjectExists(acTable, &quot;VENDOR&quot;) Then DoCmd.DeleteObject acTable, &quot;VENDOR&quot;<br>&nbsp;If ObjectExists(acTable, &quot;EMPLOYEE&quot;) Then DoCmd.DeleteObject acTable, &quot;EMPLOYEE&quot;<br>&nbsp;If ObjectExists(acTable, &quot;Exprate&quot;) Then DoCmd.DeleteObject acTable, &quot;Exprate&quot;<br>&nbsp;If ObjectExists(acTable, &quot;TblCDPeta&quot;) Then DoCmd.DeleteObject acTable, &quot;TblCDPeta&quot;<br>&nbsp;If ObjectExists(acTable, &quot;TblJobExpPeta&quot;) Then DoCmd.DeleteObject acTable, &quot;TblJobExpPeta&quot;<br>&nbsp;If ObjectExists(acTable, &quot;TblLaborSumPeta&quot;) Then DoCmd.DeleteObject acTable, &quot;TblLaborSumPeta&quot;<br>&nbsp;If ObjectExists(acTable, &quot;TblLbr&quot;) Then DoCmd.DeleteObject acTable, &quot;TblLbr&quot;<br>&nbsp;If ObjectExists(acTable, &quot;TblLbr10&quot;) Then DoCmd.DeleteObject acTable, &quot;TblLbr10&quot;<br>&nbsp;If ObjectExists(acTable, &quot;TblLbr20&quot;) Then DoCmd.DeleteObject acTable, &quot;TblLbr20&quot;<br>&nbsp;If ObjectExists(acTable, &quot;TblLbr30&quot;) Then DoCmd.DeleteObject acTable, &quot;TblLbr30&quot;<br>&nbsp;If ObjectExists(acTable, &quot;TblLbr35&quot;) Then DoCmd.DeleteObject acTable, &quot;TblLbr35&quot;<br>&nbsp;If ObjectExists(acTable, &quot;TblLbr40&quot;) Then DoCmd.DeleteObject acTable, &quot;TblLbr40&quot;<br>&nbsp;If ObjectExists(acTable, &quot;TblLbr50&quot;) Then DoCmd.DeleteObject acTable, &quot;TblLbr50&quot;<br>&nbsp;If ObjectExists(acTable, &quot;TblLbr60&quot;) Then DoCmd.DeleteObject acTable, &quot;TblLbr60&quot;<br>&nbsp;If ObjectExists(acTable, &quot;TblLbrArc&quot;) Then DoCmd.DeleteObject acTable, &quot;TblLbrArc&quot;<br>If ObjectExists(acTable, &quot;PROJECT&quot;) Then DoCmd.DeleteObject acTable, &quot;PROJECT&quot;<br>&nbsp;If ObjectExists(acTable, &quot;VENDOR&quot;) Then DoCmd.DeleteObject acTable, &quot;VENDOR&quot;<br>&nbsp;If ObjectExists(acTable, &quot;EMPLOYEE&quot;) Then DoCmd.DeleteObject acTable, &quot;EMPLOYEE&quot;<br>&nbsp;' Import records from Sema4<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acImport, &quot;FoxPro 2.6&quot;, &quot;d:\Access\Temp&quot;, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;acTable, &quot;project.dbf&quot;, &quot;PROJECT&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acImport, &quot;FoxPro 2.6&quot;, &quot;d:\Access\Temp&quot;, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;acTable, &quot;EMPLOYEE.dbf&quot;, &quot;EMPLOYEE&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acImport, &quot;FoxPro 2.6&quot;, &quot;d:\Access\Temp&quot;, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;acTable, &quot;time.dbf&quot;, &quot;TIME&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acImport, &quot;FoxPro 2.6&quot;, &quot;d:\Access\Temp&quot;, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;acTable, &quot;timearc.dbf&quot;, &quot;TIMEARC&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acImport, &quot;FoxPro 2.6&quot;, &quot;d:\Access\Temp&quot;, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;acTable, &quot;jobexp.dbf&quot;, &quot;JOBEXP&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acImport, &quot;FoxPro 2.6&quot;, &quot;d:\Access\Temp&quot;, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;acTable, &quot;jobexpac.dbf&quot;, &quot;JOBEXPAC&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acImport, &quot;FoxPro 2.6&quot;, &quot;d:\Access\Temp&quot;, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;acTable, &quot;Vendor.dbf&quot;, &quot;Vendor&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acImport, &quot;FoxPro 2.6&quot;, &quot;d:\Access\Temp&quot;, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;acTable, &quot;Exprate.dbf&quot;, &quot;Exprate&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;Beep<br>&nbsp;&nbsp;MsgBox &quot;Sema4 import is COMPLETE&quot;, vbOKOnly, &quot;BUDGET UPDATE VALIDATION&quot;<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;'Call the function to update Budget<br>&nbsp;&nbsp;compact_database<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;DoCmd.OpenQuery &quot;QEMPLOYEE&quot;, acNormal, acEdit&nbsp;&nbsp;&nbsp;'Make EMP NEW<br>&nbsp;&nbsp;DoCmd.Rename &quot;EMPLOYEE&quot;, acTable, &quot;EMPLOYEENEW&quot; 'RENAME EMPLOYEE<br>&nbsp;&nbsp;DoCmd.OpenQuery &quot;QJobExpAppnd&quot;, acNormal, acEdit<br>&nbsp;&nbsp;DoCmd.OpenQuery &quot;QTimeAppnd&quot;, acNormal, acEdit<br>&nbsp;&nbsp;DoCmd.Rename &quot;JOBEXPNEW&quot;, acTable, &quot;JOBEXP&quot;<br>&nbsp;&nbsp;DoCmd.Rename &quot;TIMENEW&quot;, acTable, &quot;TIME&quot;<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;If ObjectExists(acTable, &quot;JOBEXPAC&quot;) Then DoCmd.DeleteObject acTable, &quot;JOBEXPAC&quot;<br>&nbsp;&nbsp;If ObjectExists(acTable, &quot;TIMEARC&quot;) Then DoCmd.DeleteObject acTable, &quot;TIMEARC&quot;<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;'Call the function to update Budget<br>&nbsp;&nbsp;&nbsp;compact_database<br><br>&nbsp;&nbsp;&nbsp;&nbsp;' QJOBEXP-A<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QJobExp-N-A&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DeleteObject acTable, &quot;JOBEXPNEW&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;' QJOBEXP-B<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QJobExp-NewLnk-B&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' QJOBEXP-C<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QExprate-N-C&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' QJOBEXP-D<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QExprate-NewLnk-D&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' QJOBEXP-N<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QJobExp-Exprate-N&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' QJOBEXP-N1<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QJobexp-Exprate-N1&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' QJOBEXP-N2<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QJobExp-Exprate-N2&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' QJOBEXP-N3<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QJobExp-Exprate-N3&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' QJOBEXP-N4<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QJobExp-Exprate-N4&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' QJOBEXP-N5<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QJobExp-Exprate-N5&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' QJOBEXP-N6<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QJobExp-Exprate-N6&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeCashDisbTable<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QDetailCDPeta&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeJobExpTable<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QDetailJobExpPeta&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakePJTable<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QDetailPJPeta&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblPetaLaborTable<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLaborPeta&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblArcLbrHrsEmp Table<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QArlLbrHrsEmp&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblLbrHrsDptPhase Table<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbrHrsPhs&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTbTbllLbrCnsHrsPhs<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbrCnsHrsPhs&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblCDPeta<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QCDPeta&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblJobExpPeta<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QJobExpPeta&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTbLaborSumPeta<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLaborSumPeta&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTbLaborHrsSum<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbrSumHrs&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblLbr<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbr&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblLbr10<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbr10&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblLbr20<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbr20&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblLbr30<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbr30&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblLbr35<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbr35&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblLbr40<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbr40&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblLbr50<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbr50&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblLbr60<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbr60&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblLbrArc<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbrArc&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' WriteOffArcTotal<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QWOArcTot&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' WriteOffCnsTotal<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QWOCnsTot&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' WriteOffTots<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QWOTots&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblSASReimb<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QSASReimb&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' MakeTblSASTime<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QSASTime&quot;, acNormal, acEdit<br><br>&nbsp;&nbsp;'Call the function to update Budget<br>&nbsp;&nbsp;&nbsp;compact_database<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;' Empty Job budget Table<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;EmptyBudg&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' Update Job Budget Table with new Data #1&lt;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;TotBudg&lt;&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' Update Job Budget Table with new Data #2<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;TotBudg&lt;2&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' Update Job Budget Table with new Data #3<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;TotBudg&lt;3&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' Update Job Budget Table with new Data #4<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;TotBudg&lt;4&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' Update Job Budget Table with new Data #5<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;TotBudg&lt;5&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' Update Job Budget Table with new Data #6<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;TotBudg&lt;6&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' Update Job Budget Table with new Data #1&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;TotBudg&gt;&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' Update Job Budget Table with new Data #2<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;TotBudg&gt;2&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' Update Job Budget Table with new Data #3<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;TotBudg&gt;3&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' Update Job Budget Table with new Data #4<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;TotBudg&gt;4&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' Update Job Budget Table with new Data #5<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;TotBudg&gt;5&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;' Update Job Budget Table with new Data #6<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;TotBudg&gt;6&quot;, acNormal, acEdit<br><br>&nbsp;&nbsp;'Call the function to update Budget<br>&nbsp;&nbsp;compact_database<br><br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbrOfficeAz&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbrOfficeConc&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbrOfficeLa&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbrOfficeSac&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbrOfficeWa&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QLbrOfficeCnslt&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QReimbOfficeAz&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QReimbOfficeConc&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QReimbOfficeLa&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QReimbOfficeSac&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.OpenQuery &quot;QReimbOfficeWA&quot;, acNormal, acEdit<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;'export remote office data out for dispersal<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\Arizona&quot;, acTable, &quot;TblLaborAz&quot;, &quot;TblLaborAz&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\EB&quot;, acTable, &quot;TblLaborEb&quot;, &quot;TblLaborEb&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\LA&quot;, acTable, &quot;TblLaborLA&quot;, &quot;TblLaborLA&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\SAC&quot;, acTable, &quot;TblLaborSAC&quot;, &quot;TblLaborSAC&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\WA&quot;, acTable, &quot;TblLaborWA&quot;, &quot;TblLaborWA&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\Budget&quot;, acTable, &quot;TblLbrCn&quot;, &quot;TblLbrCn&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\Arizona&quot;, acTable, &quot;TblReimbAZ&quot;, &quot;TblReimbAZ&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\EB&quot;, acTable, &quot;TblReimbEB&quot;, &quot;TblReimbEB&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\LA&quot;, acTable, &quot;TblReimbLA&quot;, &quot;TblReimbLA&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\SAC&quot;, acTable, &quot;TblReimbSAC&quot;, &quot;TblReimbSAC&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\WA&quot;, acTable, &quot;TblReimbWA&quot;, &quot;TblReimbWA&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\Budget&quot;, acTable, &quot;PROJECT&quot;, &quot;PROJECT&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\Budget&quot;, acTable, &quot;EMPLOYEE&quot;, &quot;EMPLOYEE&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.TransferDatabase acExport, &quot;dBase IV&quot;, &quot;d:\Access\Budget&quot;, acTable, &quot;VENDOR&quot;, &quot;VENDOR&quot;, False<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DeleteObject acTable, &quot;TblLaborAz&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DeleteObject acTable, &quot;TblLaborEb&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DeleteObject acTable, &quot;TblLaborLa&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DeleteObject acTable, &quot;TblLaborSac&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DeleteObject acTable, &quot;TblLaborWa&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DeleteObject acTable, &quot;TblLbrCn&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DeleteObject acTable, &quot;TblReimbAz&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DeleteObject acTable, &quot;TblReimbEB&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DeleteObject acTable, &quot;TblReimbLA&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DeleteObject acTable, &quot;TblReimbSac&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoCmd.DeleteObject acTable, &quot;TblReimbWa&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;Beep<br>&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;The budget update is COMPLETE&quot;, vbOKOnly, &quot;BUDGET UPDATE VALIDATION&quot;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;compact_database<br><br>End Sub<br><br>Function compact_database()<br><br>&nbsp;&nbsp;&nbsp;&nbsp;SendKeys (&quot;%(W1)&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;SendKeys (&quot;%(TDC)&quot;)<br><br>End Function<br>&nbsp;&nbsp;<br><br><br><br>
 
That's one major function you have there. Way too big to be in a button on a form.<br>Can you move that function to a module. It can be moved if nothing is refering to &quot;Me!&quot; which is the current form.<br>Those references would have to be changed to<br>&nbsp;Forms![formname].... when you move it.<br><br>Then see if it compacts it.<br><br>It appears from glancing at it that it can be moved. <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
My question is:&nbsp;&nbsp;Doesn't Access close the open database, compact to a new database, delete the old and then rename the new back to the old, then reopen the new database to the form specified in the startup.&nbsp;&nbsp;So if this is the case how do you ever get pass the first compact in your procedure?<br><br>Could you place this into a Standard Code Module, break it into several functions (split after each compact).&nbsp;&nbsp;Create a table to store which function&nbsp;&nbsp;is next to be performed, then update the table as part of the code (just before doing the compact).&nbsp;&nbsp;When the database opens it calls a&nbsp;&nbsp;function (use an Autoexec Macro)&nbsp;&nbsp;that checks this table to see if the process has been completed, if not then it calls the function name stored in the table.&nbsp;&nbsp;When the process has been completed you indicate that in the table (i.e. by placing DONE as the function name), then the function will open the normal Opening form.&nbsp;&nbsp;You would still start the process by a Command Button&nbsp;&nbsp;which calls the first function, but the table, split functions, and Autoexec Macro would control the rest of it.<br><br>PaulF
 
Yes, you are right.&nbsp;&nbsp;Access closes the open database, compacts to a new one, deletes the old and renames the new back to the old.&nbsp;&nbsp;I think that's the problem.&nbsp;&nbsp;<br><br>I have tried the keycode function I described in my original message.&nbsp;&nbsp;Oddly enough, that works the first time, but not after that.<br><br>I tried the code<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If Dir(&quot;Budget.mdb&quot;) &lt;&gt; &quot;&quot; Then Kill &quot;Budget.mdb&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BEngine.CompactDatabase &quot;Budget.mdb&quot;, &quot;Budget.mdb&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Process Complete&quot; <br><br>I get an error &quot;Access denied&quot;<br><br>I need to compact the database four times because it exceeds the maximum size during this long series of events.&nbsp;&nbsp;So I need to call a procedure.<br><br>I have split the code up into separate functions as described above, but I can't figure out how to compact the database in code without closing it.<br><br>Does anyone know, and if they do could you type out the code.&nbsp;&nbsp;It's easier to understand when I
 
You must close the database in order to compact it.&nbsp;&nbsp;But if you re-read my post, the method you can follow is there. Create five functions, a new table and a autoexec macro.&nbsp;&nbsp;The first calls the other four based on an entry in the new table.&nbsp;&nbsp;The second function runs to the point where you need to compact the first time, the third until the second compact, etc.. Prior to the compact command, add a line to open the table and add the next function name to the field in the first record.&nbsp;&nbsp;Then when you get to the last function and just before the last compact set the value in the table to = Done.&nbsp;&nbsp;In the first function (which is called from the autoexec macro),&nbsp;&nbsp;open the new table, capture the function name to be run, then run the function.&nbsp;&nbsp;If the function name is Done, then Exit the function and open your normal form that you want to have displayed.&nbsp;&nbsp;To start this use a command button on one of your forms.&nbsp;&nbsp;This button can either call the second function or it can open the table and enter the second function's name, and then call the first function. <br>Does this make sense?<br><br>PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top