I am trying to write a procedure that takes an string array of field names and a tab delimited string and then splits the appropriate value for each field from the string so it can be appended with a querydef.
The code suffers a runtime error on line 30 type mismatch but I cannot work out why.
The argument arrFields is passed to the procedure as follows:
Has anyone any idea why I am getting type mismatch error?
The code suffers a runtime error on line 30 type mismatch but I cannot work out why.
Code:
Public Function AppendToTblKTM(arrFields() As String, varRecord As Variant) As Boolean
'This is a specific append query which appends to tblKTM
'NB most fields are type text but fields 7 & 8 are both date they are in the format mm/dd/yyyy which is type 101 for convert function
'varRecord is a tab delimited string representing one record
10 On Error GoTo err_AppendToTblKTM
Dim qdf As DAO.QueryDef
Dim db As Database
Dim strSQL As String
20 Dim strTable As String: strTable = "tblKTM"
Dim varValues() As Variant
Dim strRecord As String: strRecord = CStr(varRecord)
Debug.Print strRecord
30 varValues = Split(strRecord, vbTab, -1, vbTextCompare)
The argument arrFields is passed to the procedure as follows:
Code:
Dim var_record As Variant
Dim arrFields(10) As String
arrFields(0) = "KeyTask"
arrFields(1) = "Category"
arrFields(2) = "Task"
arrFields(3) = "Requirements"
arrFields(4) = "Deliverables"
arrFields(5) = "Progress"
arrFields(6) = "Owner"
arrFields(7) = "Start"
arrFields(8) = "Deadline"
arrFields(9) = "Status"
arrFields(10) = "Comments"
Has anyone any idea why I am getting type mismatch error?