473,414 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

'Object Required' error while addine new record using ADODC & MS Acces.

Hi, I am beginner in Visual Basic. I am doing a simple ADODC project using MS Acces. In that when I add new record to the database it gives me error 'Object Required'.
I tried the same code onj different form but it is giving me same error. All the connections seem ok as the data is properly fetched at startup and ADODC control works fine navigating through db.
Please help me. My code is as follows...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Set adoRecordset = New Recordset
  3.  
  4. Private Sub cmdAdd_Click()
  5.  
  6. On Error GoTo ErrLabel
  7. adoRecordset.AddNew
  8. Exit Sub
  9.  
  10. ErrLabel:
  11. MsgBox Err.Description
  12. End Sub
  13.  
Sep 27 '10 #1
2 1985
Stewart Ross
2,545 Expert Mod 2GB
Although you have defined your recordset variable and instantiated it using New you have not actually opened a recordset at all at the point where you've tried to add a new record - hence the error. You'll need to use the OpenRecordset method to open an updateable named table or query before you can add a new record. You'll also need to add code to define what field values you are going to update, as at present you don't have anything following the Addnew line at all.

-Stewart
Sep 27 '10 #2
Thanks Stewart.
I have tried your suggesion but its still not workin. also another problem is that although I have defined adoRecordset as New Recordset still when I use aadoRecordset VB doesn't prompt me method after '.'
What can be the reason?

I have tried the solution from 'Black Book' as below that too is not working. Please help.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_Load()
  3. '----------------------------------------------------
  4. Dim db As Connection
  5. Set db = New Connection
  6.  
  7. db.Open "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\Documents and Settings\Nagendra\My Documents\Shanti Nursing Home\db.mdb"
  8.  
  9. Set adoRecordset = New Recordset
  10.  
  11. adoRecordset.Open "select Fname, Hname, Lname, Age, Gage, Mchild, Fchild from Patient", db, adOpenStatic, adLockOptimistic
  12.  
  13. End Sub
  14.  
  15.  
  16. Private Sub cmdAdd_Click()
  17.  
  18. On Error GoTo ErrLabel
  19.  
  20. adoRecordset.AddNew
  21.  
  22. txtFName.Text = ""
  23. txtHName.Text = ""
  24. txtLName.Text = ""
  25. txtAge.Text = ""
  26.  
  27. Exit Sub
  28.  
  29. ErrLabel:
  30. MsgBox Err.Description
  31. End Sub
  32.  
  33.  
Sep 28 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Apostolis K. | last post by:
At first I make a independend virtual directory wich I named app and I check Directory Browsing in the Virtual Directory Properties. Then I create with notepad global.asa and index.asp ...
3
by: News Groups | last post by:
Dear Group I am trying to use the following code to refer to a form and control on my form. I am supposed to be using VBSCRIPT for this code. I always get an "object required: 'document' " error:...
1
by: contact | last post by:
Hi, I'm trying to use the following to replace a text string in all the links on a page: var arrLinks = document.links; for(var LinkIterator = 0; LinkIterator < arrLinks.length; LinkIterator++)...
7
by: google | last post by:
I am trying to use the following ASP code to examine the file names in a folder: Dim fso, f, fl, s, fs Set fso = CreateObject("Scripting.FileSystemObject") Set f =...
2
by: RICHARD BROMBERG | last post by:
I am using Access 200. I have a form which includes text boxes L1, L2 and L3 And a table tblGrades with number fields L1, L2 and L3
7
by: imatts | last post by:
Hi can anyone help with this little problem. I have a simple script to swap between two divs on a page. It works perfectly in Firefox & Safari & Opera. It fails in IE 6 giving Object Required error...
4
by: tcnjdeluca | last post by:
Hello I am sorry if this is a really novice question, but I am virtually clueless when it comes to Javascript. I have a page that is running the "leightbox" script. I have modified the script as...
6
by: jatin32 | last post by:
Hi, I have below code on Form_Load() , I get one time error when I open this form. 424 Object required, please help ASAP. Option Compare Database Private Sub Form_Load()
5
by: ash2009 | last post by:
Hi, I am getting an object required error on IE6 Line: 1826 Char:3 Code:0 When I do view Source on my browser: here's what I see for line 1826: function navBarGetMousePosition(e){
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.