Hi All

I am connecting to SQlServer using DAO.

The following code selects all the records.

Public Sub GetLists(Connect As tConnect)
' Returns any number of records.
Set GetListsCursor = New tCursor
Connect.RoutineName = "GetLists"
Dim QD As QueryDef
Set QD = Connect.DB.CreateQueryDef("", "Select NAME from Staff where Administrator = 'Y' UNION Select SHORTNAME FROM SECTORDETAILS WHERE ALPHANUMCODE NOT LIKE 'C%' AND ALPHANUMCODE NOT LIKE 'N%' UNION SELECT '#' +LISTNAME FROM USERSHARELIST WHERE UserID = " & TEmp_No & " UNION SELECT '*' +NAME FROM GROUPDETAILS ")
Set GetListsCursor.Connect = Connect
Set GetListsCursor.QD = QD
Set GetListsCursor.RS = GetListsCursor.QD.OpenRecordset(dbOpenSnapshot, dbForwardOnly And dbReadOnly)
End Sub

It returns the following error:

?err.Description
ODBC--call failed.
?err.Number
3146

I have no idea why.

Thanx