If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Checking for Table Existence before deleting
Hello All,
I would like to check to see if a table exists first before deleting it (to avoid an error). How would I do this? It seems like this should be an easy task. Thanks, Joey. |
#2
|
|||
|
|||
On Tue, 22 Mar 2005 21:17:58 GMT, Joey "jpk808[NO
wrote: Hello All, I would like to check to see if a table exists first before deleting it (to avoid an error). How would I do this? It seems like this should be an easy task. Thanks, Joey. It's easiest to simply use error trapping to detect the error, and either issue a message friendlier than the Access default or simply Resume Next. John W. Vinson[MVP] |
#3
|
|||
|
|||
Public Function funcTableExists(strTable As String) As Boolean
On Error GoTo ErrorPoint ' This function will check to see if a ' table exists within the current database ' Similar to IsLoaded function it will return True or False ' Jeff Conrad - Access Junkie Dim db As DAO.Database Dim doc As DAO.Document Set db = CurrentDb() With db.Containers!Tables For Each doc In .Documents If doc.Name = strTable Then funcTableExists = True End If Next doc End With ExitPoint: On Error Resume Next Set db = Nothing Exit Function ErrorPoint: MsgBox "The following error has occurred:" _ & vbNewLine & "Error Number: " & Err.Number _ & vbNewLine & "Error Description: " & Err.Description _ , vbExclamation, "Unexpected Error" Resume ExitPoint End Function -- Jeff Conrad Access Junkie Bend, Oregon "Joey" "jpk808[NO wrote in message news:aY%%d.759931$8l.288619@pd7tw1no... Hello All, I would like to check to see if a table exists first before deleting it (to avoid an error). How would I do this? It seems like this should be an easy task. Thanks, Joey. |
#4
|
|||
|
|||
Hi,
I had a similar question and solved it like this : Perform a command on the table and trap the error that comes when table doesn't exist. For instance : VarDummy=dcount("[field1]";"Table1") If the table doesn't exist, a trapable error occurs. This seems workable to me.....(Hope I'm right) Regards, Rudi. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Deleting a Key | barry | General Discussion | 0 | January 27th, 2005 01:07 AM |
deleting red outlined formatting marks without deleting formatted | Goldtag | Page Layout | 0 | November 19th, 2004 03:55 AM |
Deleting links without deleting the table. | Calaska | Database Design | 2 | October 21st, 2004 10:33 PM |