syntax help for SQL where ????? And ??????????

  • Thread starter Thread starter Billp
  • Start date Start date
B

Billp

Hi,

I have an sql statement

strsql = "INSERT INTO [tblsubProjectNotes] " _
& "(Works_Number" & strOtherFields & ") " _
& "SELECT '" & rst!Works_Number & "' As
NewWorks_Number" _
& strOtherFields & " FROM tblProjectNotes_Input " _
& "WHERE Works_Number='" & rst!Works_Number & "';" _
& "AND rst!Sent_Input = False"

Which returns Chaarcters found after end of SQL statement

What I would like to happen is the fields are inserted into the table where
the string works_Number = the rst!Works_Number only when the checkbox is false

Hence the Where + And , which is not working.
Thank you in advance
Regards
 
You have rst!Sent_Input inside quotes when it should be outside like
rst!Works_Number.

You don't need to add the " As NewWorks_Number"

You have a semi-colon and then "AND rst!..." The semi-colon isn't necessary
and if included, should be the last character.
 
Thank Duane,

If I do this
???????????????????????

strsql = "INSERT INTO [tblsubProjectNotes] " _
& "(Works_Number" & strOtherFields & ") " _
& "SELECT '" & rst!Works_Number & "' As
NewWorks_Number" _
& strOtherFields & " FROM tblProjectNotes_Input " _
& "WHERE Works_Number='" & rst!Works_Number & "'" _
& "AND rst!Sent_Input = False ;"

I get too few parameters expect 1

Regards



Duane Hookom said:
You have rst!Sent_Input inside quotes when it should be outside like
rst!Works_Number.

You don't need to add the " As NewWorks_Number"

You have a semi-colon and then "AND rst!..." The semi-colon isn't necessary
and if included, should be the last character.

--
Duane Hookom
Microsoft Access MVP


Billp said:
Hi,

I have an sql statement

strsql = "INSERT INTO [tblsubProjectNotes] " _
& "(Works_Number" & strOtherFields & ") " _
& "SELECT '" & rst!Works_Number & "' As
NewWorks_Number" _
& strOtherFields & " FROM tblProjectNotes_Input " _
& "WHERE Works_Number='" & rst!Works_Number & "';" _
& "AND rst!Sent_Input = False"

Which returns Chaarcters found after end of SQL statement

What I would like to happen is the fields are inserted into the table where
the string works_Number = the rst!Works_Number only when the checkbox is false

Hence the Where + And , which is not working.
Thank you in advance
Regards
 
Hi Duane,

Working - knee jerk reaction - ignore previous post - spelling mistake in
the sql statement

Regards

Duane Hookom said:
You have rst!Sent_Input inside quotes when it should be outside like
rst!Works_Number.

You don't need to add the " As NewWorks_Number"

You have a semi-colon and then "AND rst!..." The semi-colon isn't necessary
and if included, should be the last character.

--
Duane Hookom
Microsoft Access MVP


Billp said:
Hi,

I have an sql statement

strsql = "INSERT INTO [tblsubProjectNotes] " _
& "(Works_Number" & strOtherFields & ") " _
& "SELECT '" & rst!Works_Number & "' As
NewWorks_Number" _
& strOtherFields & " FROM tblProjectNotes_Input " _
& "WHERE Works_Number='" & rst!Works_Number & "';" _
& "AND rst!Sent_Input = False"

Which returns Chaarcters found after end of SQL statement

What I would like to happen is the fields are inserted into the table where
the string works_Number = the rst!Works_Number only when the checkbox is false

Hence the Where + And , which is not working.
Thank you in advance
Regards
 
Back
Top