Solved

.addnew method of a recordset

Posted on 2001-07-10
8
485 Views
Last Modified: 2013-11-25
I am trying to add a record to a recordset, and am using the following code,
but I get an error that reads.
Runtime error 3251
Object or provider not capable of performing this operation

The part the error comes from is the '.addNew' method.
RecSet is an adodb recordset, and I have copiedthe code from the msdn library.
The recordset is open in a datarepeater on another form, would that be the cause???

With recSet.AddNew
   .AddNew
   !Surname = Me.Surname.Text
   !FirstName = Me.FirstName.Text
   !Company = Me.Company.Text
   !Address = Me.Address.Text
   !Town = Me.Town.Text
   !Pcode = Me.Pcode.Text
   !ABN = Me.ABN.Text
   !UHF = Me.UHF.Text
   !Phone = Me.Phone.Text
   .Update
End With
0
Comment
Question by:cassharley
8 Comments
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 6268688
Hi,

try this:

With recSet
  .AddNew
  .Fields!Surname = Me.Surname.Text
  .Fields!FirstName = Me.FirstName.Text
  .Fields!Company = Me.Company.Text
  .Fields!Address = Me.Address.Text
  .Fields!Town = Me.Town.Text
  .Fields!Pcode = Me.Pcode.Text
  .Fields!ABN = Me.ABN.Text
  .Fields!UHF = Me.UHF.Text
  .Fields!Phone = Me.Phone.Text
  .Update
End With
0
 
LVL 1

Expert Comment

by:calebS
ID: 6268706
Is the recordset Read-only?
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6268737
Is the access file read-only? If you are using ntfs partition, you also got to make sure that write permission is granted.

hongjun
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 6

Expert Comment

by:kahlean
ID: 6268741
is ther anything to do with your reference file. What type of connection that you used?

0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6268789
I hope you are opening the recordset in readonly mode.

You could try opening the recordset like this, if I understood properly:

Set rs=new recordset
rs.open "Select * from table1",Conn1,adOpenKeySet, adLockOptimistic

rs.AddNew
:
:
rs.Update

Hope this would help you.
0
 
LVL 1

Expert Comment

by:calebS
ID: 6268811
You need to make the lock-type to 2-pessimistic, or 3-optimistic.
If he it at the defaults setting of 1-readonly.
Well obviously you can't write.

check this by opening the data designer object, and looking in the properties-->Advanced.

If your table or something else is readonly, then you will not be able to change the setting.


0
 

Author Comment

by:cassharley
ID: 6268828
Thanks, firstly the
.fields thing didn't work.

I agree with you all, the problem is because of the read-only settings,
But I checked out the database, (by actually clicking on the .mdb file) and it is not set read-only. The lock-type is readonly, but it will not let me change it.
I am not sure how to check if an individual table within the .mdb is read-only.
0
 
LVL 1

Accepted Solution

by:
calebS earned 75 total points
ID: 6268872
Try this,

On the DEConnection, click on the data link (the thing with the cord hanging off it, I am not sure if datlink is the correct term). Right-click, and choose properties.

Now choose the advanced tab, and set you read/write properties from there.

0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question