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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linked Table Error in middle of VBA Code

Status
Not open for further replies.

cariengon

Technical User
Mar 18, 2002
283
US
I have a process that runs an append query to a linked table, then it deletes the records that were just appended from the main table. I forgot to check my Linked Table Manager to be sure that it was linked, and when the process ran and tried to run the Append query, I got an error that the linked table was not found. There was no error number - just an Ok button to push. This however, did not exit me out of my code and proceeded to run the next step of deleting the records.

Is there any code that I can add that if the Linked Table is not found to exit out of the code??

Thanks,
Carie
 
There certainly is:

Function TableExists(TableName As String) As Boolean
Dim MyRst As Recordset
On Error Resume Next
Set MyRst = DBEngine.OpenDatabase(TableName)
TableExists = (Err.Number = 0)
MyRst.Close
set MyRst = nothing
End Function


You may want to add some more sophisticated error checking, but that should do the trick.

Also, if you have trouble compiling, you may need to reference DAO 3.6.
 
BEAUTIFUL!!

I will try it and let you know if it works!

Thanks,
Carie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top