473,854 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why Object Required Error

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

I am trying to use following code to add the content of the text fields (L1,
L2, L3) to a new record in the tblGrades table.

I am getting an "Object Required Error" on the Dbs.Execute strSQL
statement.

Any Suggestions would be gratly appreciated.

Private Sub cmdInsert_Click ()

Dim strSQL As String

strSQL = "INSERT INTO tblGrades" & "( L1,L2,L3 ) " & _

"SELECT '" & L1 & "', " & _

"SELECT '" & L2 & "', " & _

"SELECT '" & L3 & "', "

Dbs.Execute strSQL ' I GET OBJECT REQUIRED ERROR

Dbs.Close

End Sub
Jul 31 '06 #1
2 7847
"RICHARD BROMBERG" <no*****@att.ne twrote in
news:Iz******** *************@b gtnsc05-news.ops.worldn et.att.net:
I am getting an "Object Required Error" on the Dbs.Execute
strSQL statement.

Any Suggestions would be gratly appreciated.

Private Sub cmdInsert_Click ()
Dim strSQL As String

strSQL = "INSERT INTO tblGrades" & "( L1,L2,L3 ) " & _
"SELECT '" & L1 & "', " & _
"SELECT '" & L2 & "', " & _
"SELECT '" & L3 & "', "

Dbs.Execute strSQL ' I GET OBJECT REQUIRED ERROR
Dbs.Close

End Sub
You have neither defined nor set the database variable. Somewhere
you need:

Dim Dbas As DAO.Database

and then in the code above before you use it:

Set Dbs = [some function that returns a database pointer]

If you use CurrentDB() or DBEngine(0)(0), then you shouldn't close
it.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Jul 31 '06 #2
"RICHARD BROMBERG" <no*****@att.ne twrote in
news:Iz******** *************@b gtnsc05-news.ops.worldn et.att.net:
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

I am getting an "Object Required Error" on the Dbs.Execute
strSQL statement.

Any Suggestions would be gratly appreciated.

strSQL = "INSERT INTO tblGrades" & "( L1,L2,L3 ) " & _
"SELECT '" & L1 & "', " & _
"SELECT '" & L2 & "', " & _
"SELECT '" & L3 & "', "
this evaluates to
INSERT INTO tblgrades (L1,L2,L3) SELECT '36',SELECT '24' .

You are mixing the syntax for inserting VALUES with the sybtax
for inserting a SELECTion from another table. Since you have not
defined another table, your SELECT generates the object required
error.

There are other issues as well, you have saingle quotes aroung
L1, L2, L3. You said they are number fields; no quotes allowed.
You want
strSQL = "INSERT INTO tblGrades (L1,L2,L3)" & _
" VALUES (" & me.L1 & "," & me.L2 & "," & me.L3 & ");"

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Aug 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5885
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
8065
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
1509
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
14278
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)
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
2329
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
3517
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
2027
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
981
by: ibrahim Nohbala | last post by:
Hello. I've written a small program in MS Access 2007 that calculates how many goods left in stock in 3 different units. For example, I have a product that has 3 units of measurement: gr,kg and Piece (P). There are 1000gr in 1kg and 3.5kg in 1P. I'm collecting amounts in minimal units in this example in grams. I want the program to show me the result in all 3 units as there are 4770gr left in my stock. I have a query "mal_hereketi_tam" that...
0
9899
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
10672
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10740
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
10362
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...
0
9510
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5738
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
5937
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4550
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
3
3182
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.