Checking if a Table exists

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Client Database on a Laptop which has a Macro to link to the Master
Database on a server.

A table is created in the Client Database only if it can connect to the
Master Database. I want the Macro to exit (StopMacro) if the Table doesnt
exist or if there is no connection to the Master Database.

Is there a Macro command to check if it can connect to the Master Database
or if the Table exists (Table only exists while this Macro is running)?

Is there a way to get this info in VBA (I hate Macros)
 
There are a number of ways to do this but probably the simplest one is to
trap the error. The Create Table query will display an error if it doesn't
find the source table.

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim strSQL As String

strSQL = "SELECT LinkedTable.* INTO NewTable FROM LinkedTable;"
DoCmd.RunSQL strSQL

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox "No connection to LinkedTable."
Resume Exit_Command0_Click

End Sub
 
Back
Top