RE: Query under button



I'm using this code: but the result is
"Operations is not allowed when the object is closed."

Dim rstRS As New ADODB.Recordset
Set rstRS = New ADODB.Recordset
strSQL = "SELECT ORDefault.ORID, ORAnomalie.ANOmschr FROM " & _
"ORDefault, ORAnomalie WHERE ORDefault.ORID=3125 and " & _
"ORAnomalie.ORID=3125"
' Set rsrRS = CurrentDb.OpenRecordset(strSQL, dbOpenForwardOnly,
dbConsistent, dbReadOnly)
Set rsrRS = CurrentDb.OpenRecordset(strSQL)
Do While Not rstRS.EOF
strTextAno = strTextAno & ORAnomalie.ANOmschr & " "
Loop


"MarcVdb" schreef:

> 2 tables: a) main table with task information
> b) second table with details per task (many rows referring to same task)
>
> How and which query to run when activated by button on a form.
> Purpose: to produce a Word doc with taskdescription (from table1) and
> under the description all the rows with detail-information.
>
> The selection has to take place in code activated by the button.
> Then a loop to browse through the different returned rows (only those that
> match the task nr).
>
> (the connection to word works)
> But I'm not an expert in access and loose myself in de different docmd.
> possibilities
> or is this the wrong option to go.
> I have no idea how to make that inner selection nor how to browse trough the
> returned results without the need to show the selection-result to the user.
> The user only wants the word-doc with the details presented.
>
> I hope this is clear.
> thanks a lot.
.