Recordset not updatable

B

Brandon

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.RecordSe
Dim cn As ADODB.Connectio
Dim cmd As ADODB.Comman
Dim param As ADODB.Paramete

Set cn = CurrentProject.Connectio
Set cmd = New ADODB.Comman
With cm
.ActiveConnection = c
.CommandType = adCmdStoredPro
.CommandText = "sproc_inventory
End Wit

Set param = New ADODB.Paramete
With para
.name = "Item
.TYPE = adVarCha
.Value =sValu
.Direction = adParamInpu
.Size = 1
End Wit
cmd.Parameters.Append para

Set RecSet = New ADODB.RecordSe
With RecSe
.LockType = adLockOptimisti
.CursorType = adOpenDynami
.CursorLocation = adUseClien
End Wit

Set RecSet = cmd.Execut
Set forms("formname").RecordSet = RecSe
Set cn = Nothin
Set cmd = Nothin
Set param = Nothin

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
 
G

Gerald Stanley

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.
 
B

Brandon

Gerald

Thank you very much. Sure is a silly thing about coding. I just wish it would work both ways, but I'll take it like it is

Again Thank you

Brandon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top