Connecting Tech Pros Worldwide Forums | Help | Site Map

SQL statement Order By

Familiar Sight
 
Join Date: Nov 2006
Posts: 134
#1: Jul 5 '08
HI,
I want to set the order by desc in the sql statement, but my statement cause
BOF or EOF, what wrong with the statement ?
Expand|Select|Wrap|Line Numbers
  1. rsProcess.Open "select * from Process where SN = '" & Bd_details.Controls(Bsn).Text & " ORDER BY sn, debugno desc" & "'", conn

puppydogbuddy's Avatar
Expert
 
Join Date: May 2007
Location: Florida
Posts: 1,915
#2: Jul 5 '08

re: SQL statement Order By


Try it this way and see if it helps:
Expand|Select|Wrap|Line Numbers
  1. rsProcess.Open "select * from Process where SN = '" & Bd_details.Controls(Bsn).Text & "'" ORDER BY debugno desc" , conn 
Familiar Sight
 
Join Date: Nov 2006
Posts: 134
#3: Jul 5 '08

re: SQL statement Order By


Quote:

Originally Posted by puppydogbuddy

Try it this way and see if it helps:

Expand|Select|Wrap|Line Numbers
  1. rsProcess.Open "select * from Process where SN = '" & Bd_details.Controls(Bsn).Text & "'" ORDER BY debugno desc" , conn 

Error message display "Expected End of Statement"
puppydogbuddy's Avatar
Expert
 
Join Date: May 2007
Location: Florida
Posts: 1,915
#4: Jul 5 '08

re: SQL statement Order By


Quote:

Originally Posted by jamesnkk

Error message display "Expected End of Statement"

What part of the Sql statement was highlighted?
puppydogbuddy's Avatar
Expert
 
Join Date: May 2007
Location: Florida
Posts: 1,915
#5: Jul 5 '08

re: SQL statement Order By


Quote:

Originally Posted by puppydogbuddy

What part of the Sql statement was highlighted?

My mistake....I misread the sql...try it this way:
Expand|Select|Wrap|Line Numbers
  1. rsProcess.Open "select * from Process where SN = '" & Bd_details.Controls(Bsn).Text & "'" ORDER BY sn, debugno, desc" , conn
Familiar Sight
 
Join Date: Nov 2006
Posts: 134
#6: Jul 5 '08

re: SQL statement Order By


Quote:

Originally Posted by puppydogbuddy

My mistake....I misread the sql...try it this way:

Expand|Select|Wrap|Line Numbers
  1. rsProcess.Open "select * from Process where SN = '" & Bd_details.Controls(Bsn).Text & "'" ORDER BY sn, debugno, desc" , conn

I think you miss out & and the " before ORDER, I manage to get it right,
thank for the inspiration.
Expand|Select|Wrap|Line Numbers
  1. rsProcess.Open "select * from Process where SN = '" & Bd_details.Controls(Bsn).Text & "'" & "ORDER BY SN,Debugno desc", conn
puppydogbuddy's Avatar
Expert
 
Join Date: May 2007
Location: Florida
Posts: 1,915
#7: Jul 5 '08

re: SQL statement Order By


Yes, you are correct. Sometimes, it is hard to see unless you have the database to in front of you to work with. Glad you got it resolved.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,722
#8: Jul 8 '08

re: SQL statement Order By


Basically, it was a matter of moving the closing quote (') for the
WHERE SN='blahBla ORDER BY ... '
...so that it comes before the ORDER BY instead of somtime afterwards. The later problems were due to missing and extra double-quotes (") - which can get confusing - especially if you're rushing.

[ CODE ] tags always help to minimise these of course ;)
Reply


Similar Microsoft Access / VBA bytes