I am trying to get the string of field names in a table and then split the substring after a character. I have multiple fields with substrings that count, for example ChuckQ1 then the next field is ChuckQ2 then JawQ1 etc.
I am then trying to fill an array named strarray1 with the substring. I split it twice to not get duplicates. Please see below
Basic Example: Field name "TestQ1" and I want "1" as the split substring. If it is the first of the type, not 2 or 3..., then the second split is to grab the actual name type "Test"
I am getting type mismatch @ fldStr = Split(fldStr, "Q", 1). Please note that the first field is named "ID", tables prim key. Would that be an issue because it does not have "Q" in the string? Or is the field name not a string type?
Code
Dim f As Integer
Dim fldStr As String
Dim db As DAO.Database
Set db = CurrentDb()
Dim rs1 As DAO.Recordset
Set rs1 = db.OpenRecordset(Selection)
Dim fld As DAO.Field
f = 1
For Each fld In rs1.Fields
fldStr = fld.Name
fldStr = Split(fldStr, "Q", 1)
If fldStr = "1" Then
fldStr = fld.Name
fldStr = Split(fldStr, "Q", 0)
strArray1(f) = fldStr
f = f + 1
Else
End If
Next
Set fld = Nothing