What sbout if the string is "a" ?
You should test like this
if Len(strTemp) < 2 then
'***do what you want here is strTemp is empty
else
strSQL = strSQL & "WHERE [tblProduct].[Product ID (" & Left(strTemp,
Len(strTemp) - 2) & ")];"
end if
--
Terry Kreft
MVP Microsoft Access
"dkintheuk" <rm*******@firenet.uk.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
change the line you posted to something like...
if strTemp = "" then
'***do what you want here is strTemp is empty
else
strSQL = strSQL & "WHERE [tblProduct].[Product ID (" &
Left(strTemp, Len(strTemp) - 2) & ")];"
end if
you need to decide what to do if the string is empty... also note the
square brackets i've put in there as it looks like you are trying to
generate a field name on the fly and as such you've made it include
spaces so it needs square brackets round the whole thing...
if you meant to test the value in [tblProduct].[Product ID] then you
missed out an = sing such as...
strSQL = strSQL & "WHERE [tblProduct].[Product ID] = (" & Left(strTemp,
Len(strTemp) - 2) & ");"
as you can see the square brackets are still needed for the Product ID
field name...
does that help?
DK