473,779 Members | 2,064 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 7836
"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
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)
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
977
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
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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...
0
10139
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
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...
0
8961
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...
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...
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
3
2869
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.