By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,294 Members | 2,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,294 IT Pros & Developers. It's quick & easy.

Run time error 3061

P: n/a

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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a


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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.