janerussel
MIS
I am having a problem getting this to work for me. I want use the IfObjectExists to verify if a table exists, and if it does, delete it, otherwise go on to the next table. I want it to be in the click event of a procedure. I found the function in FAQ, but it doesn't seem to work for what I want. I have pasted my code below. Could anyone be kind enough to fix my code so that it works. I'd really appreciate it.<br><br>Private Sub RunUpdate_Click()<br> <br> If ObjectExists(acTable, "PROJECT"
Then<br> DoCmd.DeleteObject acTable, "PROJECT" else<br> <br> If ObjectExists(acTable, "VENDOR"
Then<br> DoCmd.DeleteObject acTable, "VENDOR" else<br><br> If ObjectExists(acTable, "EMPLOYEE"
Then<br> DoCmd.DeleteObject acTable, "EMPLOYEE" else <br> <br> If ObjectExists(acTable, "Exprate"
Then<br> DoCmd.DeleteObject acTable, "Exprate" else<br> EndIf<br> <br> DoCmd.TransferDatabase acImport, "FoxPro _<br> 2.6", "\\gensrvcs\sys\S480\data", _<br> acTable, "project.dbf", "PROJECT", False<br><br> DoCmd.TransferDatabase acImport, "FoxPro _<br> 2.6", "\\gensrvcs\sys\S480\data", _ <br> acTable, "EMPLOYEE.dbf", "EMPLOYEE", False<br><br> DoCmd.TransferDatabase acImport, "FoxPro _<br> 2.6", "\\gensrvcs\sys\S480\data", _<br> acTable, "time.dbf", "VENDOR", False<br><br> DoCmd.TransferDatabase acImport, "FoxPro _<br> 2.6", "\\gensrvcs\sys\S480\data", _<br> acTable, "timearc.dbf", "EXPRATE", False<br><br> <br> 'This statement checks to see if there isn't already a file with<br> 'the name of the compacted database.<br> <br> If Dir("Budget.mdb"
<> "" Then _<br> Kill "Budget.mdb"<br> EndIf <br> <br> 'This statement creates a compact version of the Budget database.<br> <br> DBEngine.CompactDatabase "Budget.mdb", "Budget.mdb"<br> <br>End Sub <br>