Newbe- method of object_recordset failed

K

Ken

I am trying to get used to working on an unbound form,
I can open a recordset without conditions, no problem, but when I try even
a simple condition I get the error in the subject.
I am just trying to open a recordset to check for duplicates, so I would
expect that if the condition isn't met I would get an EOF. I've built the
sql in a query that works, so I know the syntax is right, at least for the
query.
Here is a sample:
SELECT * FROM orders WHERE
((Orders.Section)=[Forms]![OrdersUnbound]![Section]);
Any help is greatly appreciated
 
A

Alex Dybenko

Hi,
you have to substitute a reference to control with it value:
strSQL="SELECT * FROM orders WHERE Orders.Section=" &
[Forms]![OrdersUnbound]![Section]

or, if this is a string value - then put it in quotes:


strSQL="SELECT * FROM orders WHERE Orders.Section='" &
[Forms]![OrdersUnbound]![Section] & "'"
 
K

Ken

I tried every combo I can think of and still the same error when I include
criteria in the SQL. Here is my last attemp, not even using the form
reference:
CntStr =
"Provider=Microsoft.Jet.OLEDB.4.0;" &
"DataSource=C:\Traffic\trafficdata.mdb"
SqlStr = "SELECT * FROM orders WHERE ((Orders.Section)='1109.31');"
Cnt.Open CntStr
Rst.Open SqlStr, Cnt

it will not give me an error when I dont include criteria, if I had hair I
would be pulling it out.

Alex Dybenko said:
Hi,
you have to substitute a reference to control with it value:
strSQL="SELECT * FROM orders WHERE Orders.Section=" &
[Forms]![OrdersUnbound]![Section]

or, if this is a string value - then put it in quotes:


strSQL="SELECT * FROM orders WHERE Orders.Section='" &
[Forms]![OrdersUnbound]![Section] & "'"

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com



Ken said:
I am trying to get used to working on an unbound form,
I can open a recordset without conditions, no problem, but when I try even
a simple condition I get the error in the subject.
I am just trying to open a recordset to check for duplicates, so I would
expect that if the condition isn't met I would get an EOF. I've built the
sql in a query that works, so I know the syntax is right, at least for the
query.
Here is a sample:
SELECT * FROM orders WHERE
((Orders.Section)=[Forms]![OrdersUnbound]![Section]);
Any help is greatly appreciated
 
B

Brendan Reynolds

See my post in your other thread, 'correct code please'.

--
Brendan Reynolds
Access MVP


Ken said:
I tried every combo I can think of and still the same error when I include
criteria in the SQL. Here is my last attemp, not even using the form
reference:
CntStr =
"Provider=Microsoft.Jet.OLEDB.4.0;" &
"DataSource=C:\Traffic\trafficdata.mdb"
SqlStr = "SELECT * FROM orders WHERE ((Orders.Section)='1109.31');"
Cnt.Open CntStr
Rst.Open SqlStr, Cnt

it will not give me an error when I dont include criteria, if I had hair
I
would be pulling it out.

Alex Dybenko said:
Hi,
you have to substitute a reference to control with it value:
strSQL="SELECT * FROM orders WHERE Orders.Section=" &
[Forms]![OrdersUnbound]![Section]

or, if this is a string value - then put it in quotes:


strSQL="SELECT * FROM orders WHERE Orders.Section='" &
[Forms]![OrdersUnbound]![Section] & "'"

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com



Ken said:
I am trying to get used to working on an unbound form,
I can open a recordset without conditions, no problem, but when I try
even
a simple condition I get the error in the subject.
I am just trying to open a recordset to check for duplicates, so I
would
expect that if the condition isn't met I would get an EOF. I've built
the
sql in a query that works, so I know the syntax is right, at least for
the
query.
Here is a sample:
SELECT * FROM orders WHERE
((Orders.Section)=[Forms]![OrdersUnbound]![Section]);
Any help is greatly appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top