In my Switchboard form. I want it generic. In Microsoft templates some
switchboards check that there is already company information before the
Switchboard will display itself. Well I don't want the switchboard
checking the 'Company Details' table if it doesn't exist.
Private Sub Form_Open(Cancel As Integer)
Dim dbs as Object
Dim rst as Object
If TableExist("Company Details") Then
' DoCmd.Hourglass False
' Set dbs = CurrentDb()
' Set rst = dbs.OpenRecordset("Company Details")
' If rst.RecordCount = 0 Then
' rst.AddNew
' rst![Address] = Null
' rst.Update
' MsgBox "Before using this application, you need to enter your
company name, address and related information."
' DoCmd.OpenForm "Company Details", , , , , acDialog
' End If
' rst.Close
' dbs.Close
MsgBox "Company Data Found"
Else
MsgBox "Company Data Not Found"
End If
' . . . Other Blah Blah Blah goes in here
End Sub
I hoped this would work, but didn't
Function TableExist(strTableName As String) As Boolean
Dim tbl As Table
TableExist = False
For Each tbl In Tables
If tbl.Name = strTableName Then
TableExist = True
End If
Next
End Function
Funnily enough, I used to use the ADOX.Catalogue and the ADOX.Table list
(very antiquainted now), but ADOX has become somewhat of a disasterous
topic, so I was hoping for a more generic version that will work across
2000, 2003 and 2007 platforms without corruption.
Dom