Syntax problem

P

philhood2

I keep encountering a syntax problem with the following
code used in an event procedure.

strQuerySQL4 = "SELECT * FROM Results WHERE ([Results]!
[RiderID])= " & rstRideNoChk!RiderID & " ORDER BY HeatID;"
Set rstResults = dbsCurrent.OpenRecordset(strQuerySQL4)


Can anybody tell me what I've got wrong?

Thanks

Phil.
 
G

Graham Mandeno

Hi Phil

It's hard to say, because you have not given us much to go on.

My first suspicions would be:

1. [Results]![RiderID] is a text field, so the comparison value needs to be
enclosed in quotes

2. rstRideNoChk!RiderID is Null, so you have nothing to the right of your =
sign.

If it's not one of these, set a breakpooint at the Set rstResults... line
and examine the SQL string in the debug window. If you still can't see the
problem, copy it from there and paste it into the SQL window of a new query,
then try to run the query.
 
S

Stewart Tanner

Hi Phil,

WHERE ([Results]![RiderID])= " & rstRideNoChk!RiderID & " ORDER BY HeatID;"
should be
WHERE ([Results]![RiderID]= " & rstRideNoChk!RiderID & ") ORDER BY HeatID;"
 
G

Guest

Thanks,

Problem sorted.

Phil.
-----Original Message-----
Hi Phil,

WHERE ([Results]![RiderID])= " & rstRideNoChk!RiderID & " ORDER BY HeatID;"
should be
WHERE ([Results]![RiderID]= " & rstRideNoChk!RiderID & ") ORDER BY HeatID;"

"(e-mail address removed)"
message news:[email protected]...
I keep encountering a syntax problem with the following
code used in an event procedure.

strQuerySQL4 = "SELECT * FROM Results WHERE ([Results]!
[RiderID])= " & rstRideNoChk!RiderID & " ORDER BY HeatID;"
Set rstResults = dbsCurrent.OpenRecordset(strQuerySQL4)


Can anybody tell me what I've got wrong?

Thanks

Phil.


.
 
G

Guest

Thanks,

Problem sorted.

Phil.
-----Original Message-----
Hi Phil,

WHERE ([Results]![RiderID])= " & rstRideNoChk!RiderID & " ORDER BY HeatID;"
should be
WHERE ([Results]![RiderID]= " & rstRideNoChk!RiderID & ") ORDER BY HeatID;"

"(e-mail address removed)"
message news:[email protected]...
I keep encountering a syntax problem with the following
code used in an event procedure.

strQuerySQL4 = "SELECT * FROM Results WHERE ([Results]!
[RiderID])= " & rstRideNoChk!RiderID & " ORDER BY HeatID;"
Set rstResults = dbsCurrent.OpenRecordset(strQuerySQL4)


Can anybody tell me what I've got wrong?

Thanks

Phil.


.
 

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