ms-accessvbaword-2010

Select acces datatbase in word 2010


I have to select some rows from an access in word 2010 in vba, now i would like to select some things but I get an error which says my Select is wrong can you help me ?

Private Sub CommandButton1_Click()
Dim jahr As String
Dim LfdNummer As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
jahr = TextBox1
LfdNummer = TextBox2




Private Sub CommandButton1_Click()
Dim jahr As String
Dim LfdNummer As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
jahr = TextBox1
LfdNummer = TextBox2




Set db = CreateObject("DAO.DBEngine.120").OpenDatabase("C:\User/012886\Documents\Hendrik\trilux\EMV\Beispiel_EMV.accdb")

' Daten lesen und weiterverwenden -> über Recordset

Set rs = db.OpenRecordset("SELECT * FROM ITZ-EMV-Messungen")
Do While Not rs.EOF

  rs.MoveNext
Loop


 rs.Close
 db.Close

End Sub

Solution

  • Try bracketing: [ITZ-EMV-Messungen] I reckon it is the dash.