Help with RST and Query (1 Viewer)

bonekrusher

Registered User.
Local time
Today, 13:21
Joined
Nov 19, 2005
Messages
266
Hi All,

I keep getting this message "too few parameters.Expected 1" when I run the following code. My query has a criteria in one of the fields. When I run the code with out the criteria it works, but it exports ALL the data from the table.

Code:
Dim rst As DAO.Recordset
Dim Path As String
Dim objWord As Object
Path = CurrentProject.Path & "\images\AuditCover7.dot"
objWord.Documents.Add (Path)


Set rst = CurrentDb.OpenRecordset("QryFindings")

objWord.ActiveDocument.Bookmarks("findings").Select


While Not rst.EOF
    With objWord.Selection
        .Move Unit:=4
        .InsertParagraphAfter
        .Collapse Direction:=1
        
        .TypeText (rst![findings])
        'rst![test]
    End With
   rst.MoveNext
Wend

objWord.Visible = True


Set objWord = Nothing

what am I missing?

Thanks
 

Bat17

Registered User.
Local time
Today, 21:21
Joined
Sep 24, 2004
Messages
1,687
maybe this will do it
Code:
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Set qdf = CurrentDb.QueryDefs("QryFindings")
For Each prm In qdf.Parameters
    prm.Value = Eval(prm.Name)
Next prm
Set rst = qdf.OpenRecordset()

Peter
 

bonekrusher

Registered User.
Local time
Today, 13:21
Joined
Nov 19, 2005
Messages
266
Thanks, I'll give it a try
 

Users who are viewing this thread

Top Bottom