A
alex
Loop through table def
Hello,
Using Access ’03…
I have the following code in a module (some of which graciously
provided by a member of this group):
‘’’’’’’’’’’’’’’’’’’
Function TableExists(strTable As String) As Boolean
Dim varDummy As Variant
On Error Resume Next
varDummy = CurrentDb().TableDefs(strTable)
TableExists = (Err.Number = 0&)
End Function
Function FindTable()
'used as a test for the function above
Dim strTable1 As String
Dim strTable2 As String
strTable1 = "Closed_Case_Link"
strTable2 = "Open_Case_Link"
If Not TableExists(strTable1) Then
MsgBox strTable1 & " does not exist!"
Else
MsgBox "tbl exists!"
End If
End Function
‘’’’’’’’’’’’’’’’’’’’’’’
In the function FindTable, I need to loop through (look for) about 10
tables.
I can Dim them all and set a value (you can see I’ve done two
already). I need the function, however, to look for all ten tables
and provide a message box (for each) if it cannot find any of the ten.
I could write an if statement for all ten, but that seems tedious…
there must be a better way.
I hope I’ve made sense!
Thanks for any advice.
alex
Hello,
Using Access ’03…
I have the following code in a module (some of which graciously
provided by a member of this group):
‘’’’’’’’’’’’’’’’’’’
Function TableExists(strTable As String) As Boolean
Dim varDummy As Variant
On Error Resume Next
varDummy = CurrentDb().TableDefs(strTable)
TableExists = (Err.Number = 0&)
End Function
Function FindTable()
'used as a test for the function above
Dim strTable1 As String
Dim strTable2 As String
strTable1 = "Closed_Case_Link"
strTable2 = "Open_Case_Link"
If Not TableExists(strTable1) Then
MsgBox strTable1 & " does not exist!"
Else
MsgBox "tbl exists!"
End If
End Function
‘’’’’’’’’’’’’’’’’’’’’’’
In the function FindTable, I need to loop through (look for) about 10
tables.
I can Dim them all and set a value (you can see I’ve done two
already). I need the function, however, to look for all ten tables
and provide a message box (for each) if it cannot find any of the ten.
I could write an if statement for all ten, but that seems tedious…
there must be a better way.
I hope I’ve made sense!
Thanks for any advice.
alex