Re: Recordset not updatable

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Gerald Stanley (gcstanley_at_d-s-l.pipex.com)
Date: 04/26/04


Date: Mon, 26 Apr 2004 06:19:06 -0700

Instead of
Set RecSet = cmd.Execute
Try
RecSet.Open cmd,,adOpenDynamic,adLockOptimistic

Hope This Helps
Gerald Stanley MCSD
>-----Original Message-----
>Hello,
>
>I found a help file that shows an ado recordset object
being applied to a forms recordset. I tried the example and
everything worked except that I would not allow writing the
data back to the database. I have included the following code.
>
> Dim RecSet As ADODB.RecordSet
> Dim cn As ADODB.Connection
> Dim cmd As ADODB.Command
> Dim param As ADODB.Parameter
>
> Set cn = CurrentProject.Connection
> Set cmd = New ADODB.Command
> With cmd
> .ActiveConnection = cn
> .CommandType = adCmdStoredProc
> .CommandText = "sproc_inventory"
> End With
>
> Set param = New ADODB.Parameter
> With param
> .name = "Item"
> .TYPE = adVarChar
> .Value =sValue
> .Direction = adParamInput
> .Size = 10
> End With
> cmd.Parameters.Append param
>
> Set RecSet = New ADODB.RecordSet
> With RecSet
> .LockType = adLockOptimistic
> .CursorType = adOpenDynamic
> .CursorLocation = adUseClient
> End With
>
> Set RecSet = cmd.Execute
> Set forms("formname").RecordSet = RecSet
> Set cn = Nothing
> Set cmd = Nothing
> Set param = Nothing
>
>According to the help file, I should be able to read and
write. I can only read the recordset. I get the following
error:
>Field is based on an expression and can't be edited. The
store procedure is has several joins. I know the SPROC will
work because I switched it to the recordsource and I was
able to read and write. I would prefer using the ado code.
>
>Thank you,
>
>Brandon
>.
>



Relevant Pages

  • Re: Conversion Failure?
    ... Dim recset As Recordset ... Set recset = db.OpenRecordset ...
    (microsoft.public.access.conversion)
  • Re: Conversion Failure?
    ... Dim recset As Recordset ... Set recset = db.OpenRecordset ...
    (microsoft.public.access.conversion)
  • Re: access 2003
    ... Dim ctl As Control ... Dim rs As Recordset ... This sets the query definitions for choosing data to create an invoice using ... Event on combo box: Private Sub ChooseCust_AfterUpdate ...
    (microsoft.public.access.conversion)
  • Re: Calculating Percentiles
    ... It seems that what you want then is not the percentile, ... If you want to call it repeatedly on the same recordset, ... Dim rsPercentile as DAO.Recordset ... ' Ascertain the quantile rank for a given score from the numeric ...
    (microsoft.public.access.modulesdaovba)
  • Re: A simple problem with MoveFirst
    ... update the table (rather than using the recordset) means that from ADO's ... Dim tbDataToBeEmailed As ADODB.Recordset ... tbDataToBeEmailed.Open "tbDataToBeEmailed", cnCurrent, adOpenKeyset, ... "You have not entered time into the ACIS ...
    (microsoft.public.access.modulesdaovba)