I can run this query in sql server's analyzer and it runs just fine, but when the query runs in excel half the fields are blank.. not NULL, just an empty string.
SELECT c.candidateName AS exp1, instat.status AS exp2, instat.comment AS exp3, s.state AS exp4, n.note AS exp5, avail.description AS exp6,
t.description AS exp7
FROM Candidate c LEFT OUTER JOIN
InterviewStatus instat ON c.id = instat.candidateId LEFT OUTER JOIN
States s ON s.id = c.stateId LEFT OUTER JOIN
Note n ON n.candId = c.id LEFT OUTER JOIN
Availability avail ON avail.id = c.availabilityId LEFT OUTER JOIN
Title t ON t.id = c.titleId
Here is the code to write the values to the cells...
The values that wont show up are exp7, exp6, exp5. The rest show up perfectly.
Thanks,
Greg
SELECT c.candidateName AS exp1, instat.status AS exp2, instat.comment AS exp3, s.state AS exp4, n.note AS exp5, avail.description AS exp6,
t.description AS exp7
FROM Candidate c LEFT OUTER JOIN
InterviewStatus instat ON c.id = instat.candidateId LEFT OUTER JOIN
States s ON s.id = c.stateId LEFT OUTER JOIN
Note n ON n.candId = c.id LEFT OUTER JOIN
Availability avail ON avail.id = c.availabilityId LEFT OUTER JOIN
Title t ON t.id = c.titleId
Here is the code to write the values to the cells...
Code:
Do While rs.EOF = False
If Not IsNull(rs("exp1")) Then
Range("A" & cellCount).Select
ActiveCell.Value = rs("exp1")
End If
If Not IsNull(rs("exp2")) Then
Range("G" & cellCount).Select
ActiveCell.Value = rs("exp2")
End If
If Not IsNull(rs("exp3")) Then
Range("H" & cellCount).Select
ActiveCell.Value = rs("exp3")
End If
If Not IsNull(rs("exp4")) Then
Range("B" & cellCount).Select
ActiveCell.Value = rs("exp4")
End If
If Not IsNull(rs("exp5")) Then
Range("J" & cellCount).Select
ActiveCell.Value = rs("exp5")
End If
If Not IsNull(rs("exp6")) Then
Range("F" & cellCount).Select
ActiveCell.Value = rs("exp6")
End If
If Not IsNull(rs("exp7")) Then
Range("C" & cellCount).Select
ActiveCell.Value = rs("exp7")
End If
Loop
The values that wont show up are exp7, exp6, exp5. The rest show up perfectly.
Thanks,
Greg