Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

.addnew method of a recordset

Posted on 2001-07-10
8
Medium Priority
?
494 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 53

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 225 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

597 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