The evils of cut and paste
It should have been this:
Try this syntax (use your table/field names)
Watch for line wrap....
IF [zipcode] is a number:
SQLText = "INSERT INTO MarketLookupbyZipCode ( zipcode) "
SQLText = SQLText & " SELECT [zipcode]"
SQLText = SQLText & " FROM dbo_zips
SQLText = SQLText & " WHERE [dbo_zips].[zipcode] = " &
[forms]![marketlookupbyzipcode]![zipcode1]
If [zipcode] is text:
SQLText = "INSERT INTO MarketLookupbyZipCode ( zipcode) "
SQLText = SQLText & " SELECT [zipcode]"
SQLText = SQLText & " FROM dbo_zips
SQLText = SQLText & " WHERE [dbo_zips].[zipcode] = '" &
[forms]![marketlookupbyzipcode]![zipcode1] & "';"
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)
SteveS said:
There is a close parenthesis at the end of the 3rd SQlText line that
shouldn't be there and you are missing the FROM clause in the SELECT.
Try this syntax (use your table/field names)
Watch for line wrap....
SQLText = "INSERT INTO MarketLookupbyZipCode ( zipcode) "
SQLText = SQLText & " SELECT [forms]![marketlookupbyzipcode]![zipcode1]"
SQLText = SQLText & " FROM [someTable]
SQLText = SQLText & " WHERE [someTable].[zipcode] = " &
[forms]![marketlookupbyzipcode]![zipcode1]
HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)
KSIMMSA said:
I receiving an missing operator error in the following code for the insert
procedure :
SQLText = "INSERT INTO MarketLookupbyZipCode ( zipcode) "
SQLText = SQLText & " SELECT [forms]![marketlookupbyzipcode]![zipcode1]"
SQLText = SQLText & " WHERE
[forms]![marketlookupbyzipcode]![zipcode1]=[dbo_zips].[zipcode])"
DoCmd.RunSQL SQLText
Thanks in advance for you help...