M
MarcVdb
Hello,
i'm using following SQL stmts to select rows from Table .
When moving the code to the bookmarks in a Word Document I don't see
anything appearing in my word doc.
Word opens the doc all right but then no data appears.
So if the result returns 4 rows in my recordset I want to loop 4 times and
move some of selected fields into the Word-bookmark.
Why does the code not work?
Thanks a lot for your help.
Dim Rsa As Recordset, SQL As String
Dim CurrentDB As Database
Dim Wsa As Workspace
Dim Snap As Recordset
Dim NewQry As QueryDef
SQL = "Select OpdrAnoOmsch, OpdrAnoMainrefNum from OpdrAno where
OpdrAnoMainRefNum='702005004'"
Set Wsa = DBEngine.Workspaces(0)
Set CurrentDB = Wsa.OpenDatabase("OpdrReg.mdb")
Set Rsa = CurrentDB.OpenRecordset(SQL, dbOpenDynaset)
MsgBox "done SQL Select AnoOmsch"
If Rsa.NoMatch Then
MsgBox "NoMatch"
End If
Set oApp = CreateObject("Word.Application")
oApp.Documents.Open strInputFile
Do Until Rsa.EOF
With oApp.Selection
.GoTo Name:="OpdrAnoOmschr"
.Typetext Text:=Rsa("OpdrAnoOmsch")
.GoTo Name:="OpdrMainRefNum"
.Typetext Text:=Rsa("OpdrMainRefNum")
End With
Loop
oApp.Visible = True
Rsa.Close
CurrentDB.Close
MsgBox "done3"
i'm using following SQL stmts to select rows from Table .
When moving the code to the bookmarks in a Word Document I don't see
anything appearing in my word doc.
Word opens the doc all right but then no data appears.
So if the result returns 4 rows in my recordset I want to loop 4 times and
move some of selected fields into the Word-bookmark.
Why does the code not work?
Thanks a lot for your help.
Dim Rsa As Recordset, SQL As String
Dim CurrentDB As Database
Dim Wsa As Workspace
Dim Snap As Recordset
Dim NewQry As QueryDef
SQL = "Select OpdrAnoOmsch, OpdrAnoMainrefNum from OpdrAno where
OpdrAnoMainRefNum='702005004'"
Set Wsa = DBEngine.Workspaces(0)
Set CurrentDB = Wsa.OpenDatabase("OpdrReg.mdb")
Set Rsa = CurrentDB.OpenRecordset(SQL, dbOpenDynaset)
MsgBox "done SQL Select AnoOmsch"
If Rsa.NoMatch Then
MsgBox "NoMatch"
End If
Set oApp = CreateObject("Word.Application")
oApp.Documents.Open strInputFile
Do Until Rsa.EOF
With oApp.Selection
.GoTo Name:="OpdrAnoOmschr"
.Typetext Text:=Rsa("OpdrAnoOmsch")
.GoTo Name:="OpdrMainRefNum"
.Typetext Text:=Rsa("OpdrMainRefNum")
End With
Loop
oApp.Visible = True
Rsa.Close
CurrentDB.Close
MsgBox "done3"