473,779 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'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 1998
Stewart Ross
2,545 Recognized Expert Moderator Specialist
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
5882
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 global.asa <OBJECT ID="objMyInfo" RUNAT="server" SCOPE="Application" PROGID="MSWC.MYInfo"></OBJECT> <SCRIPT Language="VBScript" RUNAT="server"> Sub Application_onStart() objMyInfo.vDailyBanner="The Big News Today is..."
3
8063
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: <% Dim Myform Set Myform = document.forms.thisform Myform.textbox1.value = "fish" %>
1
1504
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++) { if(arrLinks.firstChild.nodeValue == "More Information"){ arrLinks.firstChild.nodeValue = "More"; };
7
14268
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 = fso.GetFolder("C:\Inetpub\wwwroot\MySite\subfolder") Set fs = f.Files For Each fl in fs s = fl.Name 'Object Required error occurs here! Response.Write(s)
2
7836
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
443
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 on initializing second variable var layer2. I can't get to the bottom of this. Can anyone help? <script type="text/javascript"> function showhide(element) { var layer1 = document.getElementById('layer1').style; var layer2 =...
4
2324
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 per a suggestion on Quaint Tech so the lightbox will appear on the page load (when required). The script works great in FireFox and Safari. Clicking on a link will pull up the lightbox as it should in IE. However when I click the link that is...
6
3514
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
2024
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
9636
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10075
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.