Question : Is it possible to make access forms bound to a recordset editable using the events to update the data stored in SQL server

Hi

i have an access front end (2007) to an SQL server 2005 database.

I want to remove all links to tables and have all data rent/retreived using stored procedures.

i have a module that has all functions that returna  record set by calling a stored sproc from SQL server

Public Function GetRecordSet() As ADODB.Recordset

    Dim cnn As New ADODB.Connection
    cnn.Open sqlServerConnection
    cnn.CursorLocation = adUseClient
   
    Dim cmd As ADODB.Command
    Set cmd = New ADODB.Command
 
    cmd.ActiveConnection = cnn
    cmd.CommandType = adCmdStoredProc
    cmd.CommandText = "StoredProcName"
     
    Dim rs As New ADODB.Recordset

    Set GetRecordSet= cmd.Execute
End Function

in the form open event i include the follwing line:

Set Me.Recordset = GetRecordSet()

.....

the problem is that the form is not editable as its not linked to a table. what i want to do is have OnUpdate events on the contols that display the record that will mirror the updates made onscreen to the database.

is this possible?

thansk

jack

Answer : Is it possible to make access forms bound to a recordset editable using the events to update the data stored in SQL server

Jack,

I believe you need to do it slightly differently, as using the execute method yeilds a forward only, read only recordset.  Try it this way:

Public Function GetRecordSet() As ADODB.Recordset

   Dim cnn As New ADODB.Connection
   cnn.Open sqlServerConnection
   cnn.CursorLocation = adUseClient
   
   Dim cmd As ADODB.Command
   Set cmd = New ADODB.Command
 
   cmd.ActiveConnection = cnn
   cmd.CommandType = adCmdStoredProc
   cmd.CommandText = "StoredProcName"
     
   Dim rs As New ADODB.Recordset

   Set GetRecordSet = rs.open cmd, , adOpenKeyset, adLockOptimistic, adCmdStoredProc

End Function

JimD.

Random Solutions  
 
programming4us programming4us