I have a some vba that runs a query (which someone else wrote) and then spits out the results in an html file. Everything works as expected except for one particular field, which throws a 'Error 13 - Type Mismatch' error whenever I try and reference it. The field in the table is defined as Text, and when I view the Fields values in my recordset that particular field is of type 109 (dbComplexText). If I try to run the query itself in SQL View, it works perfectly (but the result for that field seems to be a combobox with the values already selected). I've tried testing for Null, but that isn't the problem.
The query:
Code:
Dim rs As DAO.Recordset, fs, TextFile, strSQL As String
Set fs = CreateObject("Scripting.FileSystemObject")
myPath = Application.CurrentProject.Path & "\"
myFileName = "pa.html"
Set TextFile = fs.CreateTextFile(myPath & myFileName)
strSQL = "SELECT [PA Recommendations].[Rec No], [PA Recommendations].[Recommendation Text], [NAFO Actions].[NAFO Doc No], [NAFO Actions].[Body Responsible], [NAFO Actions].[Comment], [NAFO Actions].[Timescale], [Action Status].[Progress Status] FROM ([Action Status] INNER JOIN [PA Recommendations] ON [Action Status].[Progress Status] =[PA Recommendations].[Progress Status]) INNER JOIN [NAFO Actions] ON [PA Recommendations].[Rec No] =[NAFO Actions].[Rec No] ORDER BY [PA Recommendations].[Rec No]"
Set rs = CurrentDb.OpenRecordset(strSQL)
....
' This line throws the error
TextFile.writeline ("<td>" & rs.Fields("Body Responsible") & "</td>")
Any thoughts? VBA and Access are not things I get to work with very often, so I'm hoping the answer may be obvious to others.