This is probably a dumb question and I think I know the answer but I am curious if there is something I could not find.
First here is the chunk of code I am trying
Code:
Public Function TableLinkOkay(Optional strTableName As String) As Boolean
Dim TLOqdf As DAO.QueryDef, TLOrs As DAO.Recordset, strTLOSQL As String, FullCycle As Boolean
If strTableName = "" Then
FullCycle = True
Dim item As Variant
ReDim strTableName(10) As String
strTableName(0) = "Table0"
strTableName(1) = "Table1"
strTableName(2) = "Table2"
strTableName(3) = "Table3"
strTableName(4) = "Table4"
strTableName(5) = "Table5"
strTableName(6) = "Table6"
strTableName(7) = "Table7"
strTableName(8) = "Table8"
strTableName(9) = "Table9"
strTableName(10) = "Table10"
(I omitted the extra code as I don't see it relevant to the variable/array discussion and didn't want to cause extra confusion)
When I do ?TableLinkOkay() in the immediate window I get the error "Expected Array" which I believe is due to the argument not being declared/initialized.
I have also tried rewriting it to be
Code:
Dim strTableName(10) As String
Which then tells me there is a duplicate declaration in the current scope which I expected.
I know the easy fix here would be to just create a new variable instead of trying to reuse the optional one but for the sake of learning and curiosity is there anyway of doing what I am trying to accomplish?
The objective of the optional argument is if supplied it will only test that table, if ignored/not supplied then it will test all of the tables in the redim/fullcycle.