Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. Public Function ifTableExists(tblName As String) As Boolean
  2.  
  3. ifTableExists = False
  4. If DCount("[Name]", "MSysObjects", "[Name] = '" & tblName & "'") = 1 Then
  5. ifTableExists = True
  6. End If
  7.  
  8. End Function
  9.  
  10. Exists = IsObject(CurrentDb.TableDefs(tablename))
  11.  
  12. Function IsTable(sTblName As String) As Boolean
  13. 'does table exists and work ?
  14. 'note: finding the name in the TableDefs collection is not enough,
  15. ' since the backend might be invalid or missing
  16.  
  17. On Error GoTo hell
  18. Dim x
  19. x = DCount("*", sTblName)
  20. IsTable = True
  21. Exit Function
  22. hell:
  23. Debug.Print Now, sTblName, Err.Number, Err.Description
  24. IsTable = False
  25.  
  26. End Function
  27.  
  28. SELECT Count([MSysObjects].[Name]) AS [Count]
  29. FROM MSysObjects
  30. WHERE (((MSysObjects.Name)="TblObject") AND ((MSysObjects.Type)=1));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement