database to word
I'm using this code but i'm getting an error "rs.Open("Select data*where ID = " & Text2.Text, db1, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)" I'm getting a "Syntax error (missing operator) in query expression 'data*where ID = 6'."
, I'm using vb 2005 and access 2004 any help or advice would be really helpful
Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
Dim db1 As ADODB.Connection
Dim rs As ADODB.Recordset
db1 = New ADODB.Connection
db1.Provider = "Microsoft.Jet.OLEDB.4.0;"
db1.ConnectionString = "C:\db1.mdb"
db1.Open()
rs = New ADODB.Recordset
rs.Open("Select data*where ID = " & Text2.Text, db1, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
Dim a As Object
If Not rs.EOF Then
a = vbNewLine
Call mWord.Documents.Add()
mWord.Selection.Font.Size = 12
mWord.Selection.Font.Name = "Times new roman"
mWord.Selection.Paragraphs.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight
Call mWord.Selection.TypeText(a)
Call mWord.Selection.TypeText(a)
Call mWord.Selection.TypeText(a)
Call mWord.Selection.TypeText(a)
Call mWord.Selection.TypeText(a)
Call mWord.Selection.TypeText(a)
Call mWord.Selection.TypeText(a)
mWord.Selection.Paragraphs.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft
Call mWord.Selection.TypeText(a)
Call mWord.Selection.TypeText(a)
Call mWord.Selection.TypeText(a)
Call mWord.Selection.TypeText(a)
Call mWord.Selection.TypeText(a)
Call mWord.Selection.TypeText("Name ")
Call mWord.Selection.TypeText("Author ")
Call mWord.Selection.TypeText("Location ")
Call mWord.Selection.TypeText("Description ")
While Not rs.EOF
Call mWord.Selection.TypeText(rs.Fields.Item("Name").Value + vbTab + vbTab)
Call mWord.Selection.TypeText(Str(rs.Fields.Item("Author").Value) & vbTab & vbTab)
Call mWord.Selection.TypeText(" " & Str(rs.Fields.Item("Location").Value) & vbTab)
Call mWord.Selection.TypeText(" " & Str(rs.Fields.Item("Description").Value) & vbTab)
Call mWord.Selection.TypeText(a)
rs.MoveNext()
End While
mWord.Selection.Paragraphs.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft
mWord.Selection.Font.Size = 12
db1 = Nothing
Call mWord.Documents.Item(1).SaveAs("c:\word.doc")
Call mWord.Quit()
End If
End Sub

