View Full Version : Strange problem with a query


betsyr
03-12-2002, 12:09 PM
I am opening a recordset using an SQL statement. The code is below. I am getting the error message: "Method 'Open' of object '_recordset' has failed." For some reason, the query is failing on one field. If I remove this field from the query, it works. If I susbstitute another field for this field, it works.
Why would an SQL query fail on one field? It is a normal text field with nothing different from other fields that I can determine.

Any help would be GREATLY appreciated.

Betsyr


Set rst = New Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenStatic
rst.LockType = adLockReadOnly

rst.Open Source:="SELECT [New Pieces Table].Title, [New Pieces Table].Medium, [New Pieces Table].Edition, [New Pieces Table].ArtistID, [New Pieces Table].Size FROM [New Pieces Table];", Options:=adCmdText

I am using Access 2002!

Pat Hartman
03-12-2002, 07:52 PM
Does the link to the table need to be refreshed? Does the query run from the query window? Which field has the problem? Have you tried repairing the database?

anna the third
03-13-2002, 06:04 AM
Instead of using this format to refer to your columns
[TableName].ColumnName
try using this one
[TableName].[ColumnName]

One of the names of your column might be recognized as a reserved word in Access.

anna