SQL string syntax problem

radek225

Registered User.
Local time
Today, 12:33
Joined
Apr 4, 2013
Messages
307
What is wrong with syntax of this query:/?

Code:
strsql = "Select id_poprzednie, kopiamontazu, kopiaplikow from tblPoprzednieZlecenia where id_poprzednie = select max(id_poprzednie) from tblPoprzednieZlecenia where id_tblOffset=" & Forms!frmZlecenieMarzena!Id_tblOffset & ")& "

id_tblOffset is a long
id_poprzednie is a long
 
What is wrong with syntax of this query:/?

Code:
strsql = "Select id_poprzednie, kopiamontazu, kopiaplikow from tblPoprzednieZlecenia where id_poprzednie = select max(id_poprzednie) from tblPoprzednieZlecenia where id_tblOffset=" & Forms!frmZlecenieMarzena!Id_tblOffset & ")& "
id_tblOffset is a long
id_poprzednie is a long

A lot of, put it into a new query, then you'll see. :rolleyes:
 
A lot of, put it into a new query, then you'll see. :rolleyes:

I want to use it in dao.recordset so I need it in one string:/. In clean sql it works, sqlString doesn't:/
 
made the sql (more) readable.... perhaps that will help
Code:
strsql = "Select id_poprzednie, kopiamontazu, kopiaplikow " & _
         "from   tblPoprzednieZlecenia " & _
         "where  id_poprzednie = select max(id_poprzednie) " & _
                               " from tblPoprzednieZlecenia " & _
                               " where id_tblOffset=" & Forms!frmZlecenieMarzena!Id_tblOffset & ")& "
Would seem to me like a ) and a & too many, perhaps a ( short ?
 
made the sql (more) readable.... perhaps that will help
Code:
strsql = "Select id_poprzednie, kopiamontazu, kopiaplikow " & _
         "from   tblPoprzednieZlecenia " & _
         "where  id_poprzednie = select max(id_poprzednie) " & _
                               " from tblPoprzednieZlecenia " & _
                               " where id_tblOffset=" & Forms!frmZlecenieMarzena!Id_tblOffset & ")& "
Would seem to me like a ) and a & too many, perhaps a ( short ?

Ok I will try to made more readable:).

Your syntax is wrong too:/
 
my syntax didn't attempt to fix anything, I just re-wrote your sql

if you just want a fix.

Try adding the red bracket and removing the red &
Code:
         "where  id_poprzednie = [COLOR="Red"]([/COLOR]select max(id_poprzednie) " & _
                               " from tblPoprzednieZlecenia " & _
                               " where id_tblOffset=" & Forms!frmZlecenieMarzena!Id_tblOffset & ")[COLOR="red"]&[/COLOR] "
 

Users who are viewing this thread

Back
Top Bottom