Runtime error 3251

S

Steve S

Can anybody tell me what is wong with this code? I keep getting the error
and the execution stops on the line with the arrow (->)

‘Runtime error #3251

Operation is not supported for this type of object


Dim xyz As String
xyz = [FBO To Payments subform1].Form![Pmt ID]
MsgBox ("xyz is " & xyz)
Dim dbPay As DAO.Database
Dim rcdPay As DAO.Recordset
Set dbPay = CurrentDb
Set rcdPay = dbPay.OpenRecordset("Payments")
'rcdPay.FindFirst "[Pmt ID] = [FBO To Payments subform1].Form![Pmt ID]"
-> rcdPay.FindFirst "[Pmt ID]=1588"
rcdPay.Edit
rcdPay![Amount] = Me![Original Amount]
rcdPay.Update


Thanks much
 
R

ruralguy via AccessMonster.com

Try changing this line:
Set rcdPay = dbPay.OpenRecordset("Payments")
to:
Set rcdPay = dbPay.OpenRecordset("Payments", dbOpenDynaset)



Steve said:
Can anybody tell me what is wong with this code? I keep getting the error
and the execution stops on the line with the arrow (->)

‘Runtime error #3251

Operation is not supported for this type of object

Dim xyz As String
xyz = [FBO To Payments subform1].Form![Pmt ID]
MsgBox ("xyz is " & xyz)
Dim dbPay As DAO.Database
Dim rcdPay As DAO.Recordset
Set dbPay = CurrentDb
Set rcdPay = dbPay.OpenRecordset("Payments")
'rcdPay.FindFirst "[Pmt ID] = [FBO To Payments subform1].Form![Pmt ID]"
-> rcdPay.FindFirst "[Pmt ID]=1588"
rcdPay.Edit
rcdPay![Amount] = Me![Original Amount]
rcdPay.Update

Thanks much
 
S

Steve S

That worked. thanks

I took that code from a text book. I guess they never tested it.

Steve

ruralguy via AccessMonster.com said:
Try changing this line:
Set rcdPay = dbPay.OpenRecordset("Payments")
to:
Set rcdPay = dbPay.OpenRecordset("Payments", dbOpenDynaset)



Steve said:
Can anybody tell me what is wong with this code? I keep getting the error
and the execution stops on the line with the arrow (->)

‘Runtime error #3251

Operation is not supported for this type of object

Dim xyz As String
xyz = [FBO To Payments subform1].Form![Pmt ID]
MsgBox ("xyz is " & xyz)
Dim dbPay As DAO.Database
Dim rcdPay As DAO.Recordset
Set dbPay = CurrentDb
Set rcdPay = dbPay.OpenRecordset("Payments")
'rcdPay.FindFirst "[Pmt ID] = [FBO To Payments subform1].Form![Pmt ID]"
-> rcdPay.FindFirst "[Pmt ID]=1588"
rcdPay.Edit
rcdPay![Amount] = Me![Original Amount]
rcdPay.Update

Thanks much
 
R

ruralguy via AccessMonster.com

Glad I could help Steve.

Steve said:
That worked. thanks

I took that code from a text book. I guess they never tested it.

Steve
Try changing this line:
Set rcdPay = dbPay.OpenRecordset("Payments")
[quoted text clipped - 22 lines]
 
A

Allen Browne

Just to clarify, Steve, you can get away without specifying dbOpenDynaset if
you OpenRecordset() on a query statement or an attached table (i.e. it's the
default for these types), but not on a table in the same database (since
dbOpenTable is the default kind.)

This is trap #2 in this article:
Traps: Working with Recordsets
at:
http://allenbrowne.com/ser-29.html#Recordset_Type

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Steve S said:
That worked. thanks

I took that code from a text book. I guess they never tested it.

Steve

ruralguy via AccessMonster.com said:
Try changing this line:
Set rcdPay = dbPay.OpenRecordset("Payments")
to:
Set rcdPay = dbPay.OpenRecordset("Payments", dbOpenDynaset)



Steve said:
Can anybody tell me what is wong with this code? I keep getting the
error
and the execution stops on the line with the arrow (->)

'Runtime error #3251

Operation is not supported for this type of object

Dim xyz As String
xyz = [FBO To Payments subform1].Form![Pmt ID]
MsgBox ("xyz is " & xyz)
Dim dbPay As DAO.Database
Dim rcdPay As DAO.Recordset
Set dbPay = CurrentDb
Set rcdPay = dbPay.OpenRecordset("Payments")
'rcdPay.FindFirst "[Pmt ID] = [FBO To Payments subform1].Form![Pmt
ID]"
-> rcdPay.FindFirst "[Pmt ID]=1588"
rcdPay.Edit
rcdPay![Amount] = Me![Original Amount]
rcdPay.Update

Thanks much
 
D

Dirk Goldgar

Steve S said:
That worked. thanks

I took that code from a text book. I guess they never tested it.

It would work if [Payments] were a query, not a table. The
OpenRecordset method returns a different type of recordset, by default,
for a local table than for a query or linked table. The table-type
recordset normally opened for a local table doesn't support the
FindFirst method. It does support the Seek method, which a dynaset-type
recordset doesn't.
 

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

Similar Threads


Top