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

Run time error 3061


I have an error with the following code
Dim rs As DAO.Recordset

Set dbs = CurrentDb

strSQL = "SELECT * FROM table1 WHERE table1.Schedule_Item LIKE
""AA"" AND table1.Item1 = " & Form!Item1

Set rs = dbs.OpenRecordset(strSQL, dbOpenDynaset)

How can I fix it, anyhelp would be great

Thank you
--------------------------------------------------------------------------


Nov 12 '05 #1
3 1973
On Sun, 4 Jan 2004 18:13:26 +1100, "Tu Quach"
<qu********@optusnet.com.au> wrote:

I have an error with the following code
Dim rs As DAO.Recordset

Set dbs = CurrentDb

strSQL = "SELECT * FROM table1 WHERE table1.Schedule_Item LIKE
""AA"" AND table1.Item1 = " & Form!Item1

Set rs = dbs.OpenRecordset(strSQL, dbOpenDynaset)

How can I fix it, anyhelp would be great

Thank you


What exactly is the error? Like it would help if you gave some
insight about the error message. Perhaps no dim for dbs or perhaps
incorrect data type for Item1 or perhaps the And statement rather than
concatenation.

Maybe you could put a break point before opening the rs and
debug.print the strSQL and then paste that into a SQL view of a new
query which may give some light on the problem.

If this does not make sense to you, please come back to the newsgroup
Nov 12 '05 #2


Tu Quach wrote:
I have an error with the following code

Dim rs As DAO.Recordset

Set dbs = CurrentDb

strSQL = "SELECT * FROM table1 WHERE table1.Schedule_Item LIKE
""AA"" AND table1.Item1 = " & Form!Item1

Set rs = dbs.OpenRecordset(strSQL, dbOpenDynaset)

How can I fix it, anyhelp would be great

Thank you

--------------------------------------------------------------------------


Dim strSQL As String
strSQL = "SELECT Table1.* FROM Table1 " & _
"WHERE Table1.ScheduleItem Like ""AA"" AND Table1.Item1 = '" & 1 & "'"

I substituted the number 1 for Form!Item1. Did you notice I surrowned the 1
with a single quote. I figured Item1 is a text value, not numeric. Remember,
text items need to be surrounded by quotes, dates with #, and numbers have
nothing.

PS. If you post messages with error numbers, most people responding WILL NOT
look up the error codes to determine what it is. You might want to supply the
description of error codes in future posts. Since I didn't look it up, the
above may not have solved your problem.

Nov 12 '05 #3
try to use this string (chr(34) instead of ")

strsql="SELECT * FROM table1 WHERE table1.Schedule_Item LIKE " & chr(34) &
"AA" & chr(34) & " AND table1.Item1 = " & Form!Item1

Laurent descombes

"Tu Quach" <qu********@optusnet.com.au> a écrit dans le message news:
3f***********************@news.optusnet.com.au...

I have an error with the following code
Dim rs As DAO.Recordset

Set dbs = CurrentDb

strSQL = "SELECT * FROM table1 WHERE table1.Schedule_Item LIKE
""AA"" AND table1.Item1 = " & Form!Item1

Set rs = dbs.OpenRecordset(strSQL, dbOpenDynaset)

How can I fix it, anyhelp would be great

Thank you
--------------------------------------------------------------------------

Nov 12 '05 #4

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

Similar topics

0
by: Miranda Evans | last post by:
I noticed several postings about issues related to "run-time error 3061", and I observed that the solutions to these issues appear to involve correcting something within the SQL code. I'm...
2
by: Jon | last post by:
Hello all: I'm trying to modify an existing db for someone who wants to set appointments in a customer db. They want to prevent someone from double booking appts. I've developed a few lines...
2
by: Steve Richfield | last post by:
There have been LOTS of postings about error 3061, but mine seems to be an even simpler case than the others. I have a simple **FUNCTIONING** query called qryEdits. Copying the SQL from the query,...
4
by: Richard Hollenbeck | last post by:
I thought I was very specific in this SQL request. There is a form open with a selected record (and a corresponding "lngRecipeID" on that form. The table also has a field called "lngRecipeID". ...
1
by: Richard Hollenbeck | last post by:
I wonder what I'm missing? I really feel like a retard because I've been screwing with some code for a very long time. I just must be missing something very simple. In the following example,...
1
by: istya | last post by:
I am having a dumb day to day. Can anyone have a schufty at my code and see why I am getting the runtime error 3061? I'm working on 2000 if that helps at all. Dim dbs As DAO.Database Dim...
3
by: ragtopcaddy via AccessMonster.com | last post by:
I have an error handler: On Error GoTo Outtahere At the end of the routine, the OuttaHere section reads: OuttaHere: If Err.Number <0 Then If Err.Number = 3061 Then Debug.Print " Failed to...
1
atksamy
by: atksamy | last post by:
i have the following code On Error GoTo TableTest_Error Set rs3 = CurrentDb.OpenRecordset(strsql3) GoTo continue ...
3
by: phill86 | last post by:
Hi, I am trying to run the following query in a recordset and i get the following error message Runtime error 3061 - Too few parameters. Expected 1 i am using the following code
8
Cintury
by: Cintury | last post by:
The problem is I have a function that I've created and stored in a module. I call it as an expression (e.g. total: Function(parameter)). I'm receiving the error 3061: too few parameters, expected 1....
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.