S
ScottA
I am trying to create a recordset which can later be
exported to Word as a table. This recordset includes
details of documents distributed to a list of recipients.
The button I'm using for launching the code is attached to
the recipient form (the Me here in the code) - I want to
create a recordset that includes details for only those
documents that have been sent to the recipient displayed.
When I try to run the code, I am getting a Type Mismatch
error at the point when the recordset should be created.
Can anyone tell me what I might be doing wrong?
Thanks,
Scott A
Here's the code:
==========================================================
Private Sub cmdWord_Click()
On Error GoTo Err_cmdWord_Click
Dim db As Database
Dim recDocList As Recordset
Dim strSQL As String
Dim strDocs As String
Set db = CurrentDb()
strSQL = "SELECT * FROM qryDistDetail " & _
"WHERE (((tblDistributions.RecipientID) = " & Me!
RecipientID & "))"
Set recDocList = db.OpenRecordset(strSQL)
strDocs = "Title" & vbTab & "Doc No." & vbTab
& "Version" & vbCr
While Not recDocList.EOF
strDocs = strDocs & vbCrLf & recDocList
("DocTitle") & vbTab & _
recDocList("DocCode") & vbTab & _
recDocList("DocVersion")
recDocList.MoveNext
Wend
CreateDocAOR recDocList
recDocList.Close
Exit_cmdWord_Click:
Exit Sub
Err_cmdWord_Click:
MsgBox Err.Description
Resume Exit_cmdWord_Click
End Sub
exported to Word as a table. This recordset includes
details of documents distributed to a list of recipients.
The button I'm using for launching the code is attached to
the recipient form (the Me here in the code) - I want to
create a recordset that includes details for only those
documents that have been sent to the recipient displayed.
When I try to run the code, I am getting a Type Mismatch
error at the point when the recordset should be created.
Can anyone tell me what I might be doing wrong?
Thanks,
Scott A
Here's the code:
==========================================================
Private Sub cmdWord_Click()
On Error GoTo Err_cmdWord_Click
Dim db As Database
Dim recDocList As Recordset
Dim strSQL As String
Dim strDocs As String
Set db = CurrentDb()
strSQL = "SELECT * FROM qryDistDetail " & _
"WHERE (((tblDistributions.RecipientID) = " & Me!
RecipientID & "))"
Set recDocList = db.OpenRecordset(strSQL)
strDocs = "Title" & vbTab & "Doc No." & vbTab
& "Version" & vbCr
While Not recDocList.EOF
strDocs = strDocs & vbCrLf & recDocList
("DocTitle") & vbTab & _
recDocList("DocCode") & vbTab & _
recDocList("DocVersion")
recDocList.MoveNext
Wend
CreateDocAOR recDocList
recDocList.Close
Exit_cmdWord_Click:
Exit Sub
Err_cmdWord_Click:
MsgBox Err.Description
Resume Exit_cmdWord_Click
End Sub