cassharley
asked on
.addnew method of a recordset
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
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
Is the recordset Read-only?
Is the access file read-only? If you are using ntfs partition, you also got to make sure that write permission is granted.
hongjun
hongjun
is ther anything to do with your reference file. What type of connection that you used?
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.
You could try opening the recordset like this, if I understood properly:
Set rs=new recordset
rs.open "Select * from table1",Conn1,adOpenKeySet
rs.AddNew
:
:
rs.Update
Hope this would help you.
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.
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.
ASKER
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.
.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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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