THanks for this. I've put it into a function which I've called on the on open/on update actions for the form so the info automatically outputs but it seems to be skipping a lot of the code. I've put a watch on the qdf and it definitely returns the right records but the function seems to skip lines as follows:
Public Function LoadSubCats()
Dim tempRecordset As DAO.Recordset
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim StrText As String
StrText = vbNullString
Set db = CurrentDb
Set qdf = db.QueryDefs("qrySubCat")
-------------------------------
SKIPS FROM HERE
------------------------------------
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set tempRecordset = qdf.OpenRecordset
With tempRecordset
If Not tempRecordset.BOF And Not tempRecordset.EOF Then
tempRecordset.MoveFirst
Do Until tempRecordset.EOF = True
StrText = "," & StrText
tempRecordset.MoveNext
Loop
'get rid of the leading comma
If Len(StrText) > 1 Then
Forms!FRMContractInfo.[txtSubCat] = Right(StrText, Len(StrText) - 1)
Else
Forms!FRMContractInfo.[txtSubCat] = Null
End If
End If
tempRecordset.Close
---------------------------------------
TO HERE
---------------------------------------
Set tempRecordset = Nothing
Set qdf = Nothing
Set db = Nothing
End With
End Function
Have I done something wrong?
