C
Clayman
I am trying to pull the results of an SQL query into a series of variables.
When I execute the code, I get various "Not Defined" errors regarding the
format of my assignment.
Here's my SQL:
sSQL = "SELECT EmpData.[FirstName], EmpData.[LastName],
EmpData.[HireDate], " & _
"CurrentData.[VacRate] FROM EmpData, CurrentData WHERE
EmpData.[FileNumber] = " & _
StrFileNum & " AND CurrentData.[FileNumber] = " & StrFileNum & ";"
Set VacRS = VacConn.Execute(sSQL)
If I use:
StrFirstName = VacRS!(EmpData.[FirstName])
Excel will turn FirstName into firstname and tell me EmpData is not defined.
If I use:
StrFirstName = VacRS!([FirstName])
Excel will turn FirstName into firstname and tell me Type-declaration
character does not match declared data type (with VacRS highlighted).
If I use:
StrFirstName = VacRS!(FirstName)
Excel turns FirstName into firstname and tells me it is not defined.
Funny thing though:
StrLastName = VacRS!(LastName)
works without a problem.
I have checked, and the word FirstName is only used in the SQL, the
assignment to StrFirstName and in the word StrFirstName itself.
Ideas?
When I execute the code, I get various "Not Defined" errors regarding the
format of my assignment.
Here's my SQL:
sSQL = "SELECT EmpData.[FirstName], EmpData.[LastName],
EmpData.[HireDate], " & _
"CurrentData.[VacRate] FROM EmpData, CurrentData WHERE
EmpData.[FileNumber] = " & _
StrFileNum & " AND CurrentData.[FileNumber] = " & StrFileNum & ";"
Set VacRS = VacConn.Execute(sSQL)
If I use:
StrFirstName = VacRS!(EmpData.[FirstName])
Excel will turn FirstName into firstname and tell me EmpData is not defined.
If I use:
StrFirstName = VacRS!([FirstName])
Excel will turn FirstName into firstname and tell me Type-declaration
character does not match declared data type (with VacRS highlighted).
If I use:
StrFirstName = VacRS!(FirstName)
Excel turns FirstName into firstname and tells me it is not defined.
Funny thing though:
StrLastName = VacRS!(LastName)
works without a problem.
I have checked, and the word FirstName is only used in the SQL, the
assignment to StrFirstName and in the word StrFirstName itself.
Ideas?