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


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
 
Ad

Advertisements

D

Duane Hookom

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.
 
B

Billp

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
 
Ad

Advertisements

B

Billp

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
 

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