J
John Sanders
OK, I'm probably missing something basic here.
I get a run-time error 3065, cannot execute a select query.
The code seems to compile fine:
....
Dim testqry As DAO.QueryDef
Dim TestDB As DAO.Database
Dim SQLString As String
Stop
SQLString = "SELECT * FROM " & Me.Recordset.Name & " WHERE (" &
Me.Recordset.Name & _
".[employee name] = """
SQLString = SQLString & "Jester"
' This will be replaced with a variable when I get it to execute
SQLString = SQLString & """);"
Debug.Print SQLString
Set TestDB = CurrentDb
Set testqry = TestDB.CreateQueryDef("", SQLString)
testqry.Execute
...
The generated SQL string is
SELECT * FROM tbl_Employees WHERE (tbl_Employees.[employee name] =
"Jester");
When I save that string as a query outside the form, it will execute
fine. Inside the form, it crashes on the testqry.execute line with the
run-time error.
I have as references:
Visual Basic For Applications
Microsoft Access 9.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library
I am running Access 2000 on a local machine with a local single-user
database.
Thanks for any help--this is getting me frustrated.
John Sanders
PersonalIT at Juno dot Com
I get a run-time error 3065, cannot execute a select query.
The code seems to compile fine:
....
Dim testqry As DAO.QueryDef
Dim TestDB As DAO.Database
Dim SQLString As String
Stop
SQLString = "SELECT * FROM " & Me.Recordset.Name & " WHERE (" &
Me.Recordset.Name & _
".[employee name] = """
SQLString = SQLString & "Jester"
' This will be replaced with a variable when I get it to execute
SQLString = SQLString & """);"
Debug.Print SQLString
Set TestDB = CurrentDb
Set testqry = TestDB.CreateQueryDef("", SQLString)
testqry.Execute
...
The generated SQL string is
SELECT * FROM tbl_Employees WHERE (tbl_Employees.[employee name] =
"Jester");
When I save that string as a query outside the form, it will execute
fine. Inside the form, it crashes on the testqry.execute line with the
run-time error.
I have as references:
Visual Basic For Applications
Microsoft Access 9.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library
I am running Access 2000 on a local machine with a local single-user
database.
Thanks for any help--this is getting me frustrated.
John Sanders
PersonalIT at Juno dot Com