Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with a WHERE clause... 1

Status
Not open for further replies.

briglass

Programmer
Dec 4, 2001
179
0
0
GB
Hello,

I am trying to merge table1 with table2, but only when the "section" column has a certain value. The statement worked fine until I added the last WHERE clause. I get the error "Too Few Parameters. Expected 1."

The error explanation on the Microsoft website says, "you refer to a column in a table that does not exist."

I checked, and the column name is correct ("section").

I should also note that the tables have an AutoNumber field and an ID field... does that make a difference?

Any suggestions?


Code:
For dist = 1 To 28
    If checkMerge(dist).Value = 1 Then
        strsql$ = "INSERT INTO table1 SELECT table2.* FROM table2 WHERE section = " & namearray(dist) & ";"
        db.Execute strsql$
    End If
Next dist

Thanks, (-:
Brian
 
Assuming that the field section is a text field, it needs quotes around the value. Try this
Code:
For dist = 1 To 28
    If checkMerge(dist).Value = 1 Then
        strsql$ = "INSERT INTO table1 SELECT table2.* FROM table2 WHERE section = '" & namearray(dist) & "';"
        db.Execute strsql$
    End If
Next dist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top