-
I have declared the following in a bas module.
Public cnMainData As Connection
Public rs As Recordset
Then in the form load event I wrote
Set cnMainData = New Connection
Set rs = New Recordset
With cnMainData
.Provider = "Microsoft.Jet.OLEDB.3.51"
.ConnectionString = "c:\Anita\db1.mdb"
.Open
End With
With rs
.Open "Employer", cnMainData, adOpenDynamic
.AddNew
!CompanyName = Text1.Text
!Vocation = Text2.Text
!ContactPerson = Text3.Text
!Address = Text4.Text
!city = Text5.Text
!ZipCode = Text6.Text
!Phoneno = Text7.Text
!FaxNo = Text8.Text
!EmailId = Text9.Text
!PreviousPlacements = Text10.Text
.Update
End With
It is giving a run-time error 3251
for rs.addnew.
" The operation required by the application is not supported by the provider.
If I declare
Public cnMainData As ADODB.Connection
Public rs As ADODB.Recordset
it is giving the same result.
-
You have opened the recordset in the default locking mode i.e. read only mode. Therefore you are unable to add records to it.
Instead of this
.Open "Employer", cnMainData, adOpenDynamic
try this
.Open "Employer", cnMainData, adOpenDynamic,adlockoptimistic
It will work
-
Thank you so much.It is working!!!!!!!Yesterday I spent so many hours trying to solve the problem.