Insert Into Query

G

Guest

I have three buttons on a nomination form, if users click on any of the
button I want the contact name and other information for that particular
record to be inserted into a table. I used the following code:

Dim SQL As String
Dim strWhere As String

strWhere = Me.Contact_LastName

SQL = "INSERT INTO tblteams " & _
"(teamname) " & _
"SELECT Contact_LastName FROM Results Where =" & strWhere & "'"

DoCmd.RunSQL SQL

But it keeps giving me syntax error in the Where clause can someone please
help me?

Thanks
 
G

Guest

You are missing your field name from your results table and the opening
single quote
"SELECT Contact_LastName FROM Results Where [FieldName]='" & strWhere & "'"
 

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

Similar Threads

Insert Into Query 5
SQL Not Working 5
creating search box in vba 7
Str where and muliple criteria problem 11
Code for List Boxes 17
Syntax Error in Query Expression 2
CODE HELP! 2
visual basic help... 3

Top