Solved

.addnew method of a recordset

Posted on 2001-07-10
8
479 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 49

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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now