When I run my code, I get this "object variable or with block variable not set" error message.
A, B, C, D, E, F are the names of the existing check boxes on the form. I'm trying to access it using array in this function.
Can anyone please help me to solve this problem. I'm thinking it's about my object reference problem. And I'm new to VB.
Thanks so much.
Code:
Public Function fGetHeaderList() As String
Dim strList(5) As CheckBox
Dim i As Integer
fGetHeaderList = "SELECT "
strList(0) = "A"
strList(1) = "B"
strList(2) = "C"
strList(3) = "D"
strList(4) = "E"
strList(5) = "F"
For i = LBound(strList) To UBound(strList)
If (i = 5 And strList(i).Value) Then
fGetHeaderList = fGetHeaderList + "table1." + strList(5)
Else
If (strList(i).Value) Then
fGetHeaderList = fGetHeaderList + "table1." + strList(i) + ", "
End If
End If
Next
If (fGetHeaderList <> "SELECT ") Then
fGetHeaderList = fGetHeaderList + " FROM table1 INNER JOIN table2 ON table1.A = table2.key"
End If
End Function
Can anyone please help me to solve this problem. I'm thinking it's about my object reference problem. And I'm new to VB.
Thanks so much.
Comment