Hi
Regarding the field type, does it make any difference ? because the error was returned on the first line and even when I removed
rstVacTypes.Fields("Ref"
= txtRef.text it still gave me the error. Anyway, the field type is 3 (autonumber in the access database)
The problem is that I have the following function to do all the retrieval of recordsets.
conGlobal is a global connection I open before.
Public Function Retrieve(ByVal strSql As String, Optional ByVal CursorType As CursorTypeEnum = adOpenDynamic, Optional ByVal LockType As LockTypeEnum = adLockPessimistic) As ADODB.Recordset
Dim ADORecordset As ADODB.Recordset
Set ADORecordset = New ADODB.Recordset
'the location must be set to client so that the datagrid can be bound
'at runtime
ADORecordset.CursorLocation = adUseClient
ADORecordset.Open strSql, conGlobal, adOpenKeyset
Set Retrieve = ADORecordset
End Function
When I use this function to return the recordset:
set rst = Retrieve("SELECT * FROM VacTypes"
I get the error and the cursortype becomes "static" when the recordset is passed even though I am setting it to dynamic in the function.
The rstvactypes.supports(adupdate) returns false.
When I open the recordset there and then and replace
set rst = Retrieve("SELECT * FROM Vactypes"
with :
sSQLstring = "SELECT * FROM VacTypes WHERE Ref = 5
rstVacTypes.Open sSQLstring, conGlobal, adOpenDynamic, adLockPessimistic
it works out fine.
Any ideas what the problem might be.
Thanks for the interest.