K
Krzysztof via AccessMonster.com
Good Afternoon,
I have a question i cannot seem to answer.
I have 2 arrays and a loop that perform certain functions, and when i call
this sub, i get and error message stating: "Compile Error: byRef Argument
Type Mismatch".
I am not sure what that means, but i have tried replacing the array
identifier with a variable, but whatever i do, i get the same message.
Here is a copy of the code:
Here is my function
Public Function TableExists(strTableName As String) As Boolean
On Error Resume Next
TableExists = IsObject(CurrentDb.TableDefs(strTableName))
End Function
And here is the sub
Public Sub CaptureData()
Dim Tables(3, 0), Queries(3, 0) As String
Tables(0, 0) = "tbl_INVOICE"
Tables(1, 0) = "tbl_WOITEMS"
Tables(2, 0) = "tbl_WRKORDER"
Tables(3, 0) = "tbl_EMPLOYEE"
Queries(0, 0) = "mtqry_Invoice"
Queries(1, 0) = "mtqry_WOItems"
Queries(2, 0) = "mtqry_Wrkorder"
Queries(3, 0) = "mtqry_Employee"
'===============================================
'Create local tables
'Check to see if local table exists and if so, delete it
Me.bonus_progress.Visible = True 'activate the progress bar
Me.bonus_progress.value = 0 'reset the progress bar
Dim i As Integer
For i = 0 To 3
If TableExists(Tables(i,0)) = True Then 'check to see if table
exists
DoCmd.DeleteObject acTable, Tables(i,0) 'if so, deletes it
Else
'do nothing
End If
DoCmd.OpenQuery Queries(i,0), acViewNormal 'rerun the query to
create new, updated table
Me.bonus_progress.value = Me.bonus_progress.value + 25
'increment the progress bar
Loop
'===============================================
Me.bonus_progress.Visible = False 'deactivate the progress bar
End Sub
Right after i set up the loop "Tables(i,0)" is what is highlighted.
Any ideas?
I have a question i cannot seem to answer.
I have 2 arrays and a loop that perform certain functions, and when i call
this sub, i get and error message stating: "Compile Error: byRef Argument
Type Mismatch".
I am not sure what that means, but i have tried replacing the array
identifier with a variable, but whatever i do, i get the same message.
Here is a copy of the code:
Here is my function
Public Function TableExists(strTableName As String) As Boolean
On Error Resume Next
TableExists = IsObject(CurrentDb.TableDefs(strTableName))
End Function
And here is the sub
Public Sub CaptureData()
Dim Tables(3, 0), Queries(3, 0) As String
Tables(0, 0) = "tbl_INVOICE"
Tables(1, 0) = "tbl_WOITEMS"
Tables(2, 0) = "tbl_WRKORDER"
Tables(3, 0) = "tbl_EMPLOYEE"
Queries(0, 0) = "mtqry_Invoice"
Queries(1, 0) = "mtqry_WOItems"
Queries(2, 0) = "mtqry_Wrkorder"
Queries(3, 0) = "mtqry_Employee"
'===============================================
'Create local tables
'Check to see if local table exists and if so, delete it
Me.bonus_progress.Visible = True 'activate the progress bar
Me.bonus_progress.value = 0 'reset the progress bar
Dim i As Integer
For i = 0 To 3
If TableExists(Tables(i,0)) = True Then 'check to see if table
exists
DoCmd.DeleteObject acTable, Tables(i,0) 'if so, deletes it
Else
'do nothing
End If
DoCmd.OpenQuery Queries(i,0), acViewNormal 'rerun the query to
create new, updated table
Me.bonus_progress.value = Me.bonus_progress.value + 25
'increment the progress bar
Loop
'===============================================
Me.bonus_progress.Visible = False 'deactivate the progress bar
End Sub
Right after i set up the loop "Tables(i,0)" is what is highlighted.
Any ideas?