Problem with SQL Query in Visual Basic - TechRepublic
General discussion
September 14, 2005 at 09:26 AM
twhite

Problem with SQL Query in Visual Basic

by twhite . Updated 20 years, 9 months ago

The following query works if I remove the “tblLocations.PrimaryFlag=-1” from the WHERE statement. I wanted to see if anyone could tell me what I am doing wrong. I have also tried “tblLocations.[PrimaryFlag]=’-1′” and “(((tblLocations.PrimaryFlag)=-1))”. I need to be able to filter for records with a -1 result for PrimaryLocation (Which is a Yes/No field in Microsoft Access 2003).

strSQL = “INSERT INTO tvwCustomers ( CustomerID, CFirst, CLast, ” & _
“CustomerType, BusinessName, CCity, CState, PrimaryFlag ) ” & _
“SELECT tblCustomers.CustomerID, tblCustomers.CFirst, tblCustomers.CLast, ” & _
“tblCustomers.CustomerType, tblCustomers.BusinessName, tblLocations.CCity, ” & _
” tblLocations.CState, tblLocations.PrimaryFlag ” & _
“FROM tblLocations INNER JOIN tblCustomers ON tblLocations.CustomerID = tblCustomers.CustomerID ” & _
“WHERE tblLocations.PrimaryFlag=-1 ” & varSQLWhere

This discussion is locked

All Comments