473,386 Members | 1,712 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,386 software developers and data experts.

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 7816
"RICHARD BROMBERG" <no*****@att.netwrote in
news:Iz*********************@bgtnsc05-news.ops.worldnet.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.netwrote in
news:Iz*********************@bgtnsc05-news.ops.worldnet.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
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 =...
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: 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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...

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.