PDA

View Full Version : Problem with WHERE expression



linkerschuh
02-09-2015, 12:44 PM
Hi all,

I have a table with miscellaneous fields. One field is called "Registered Countries". Other fields are country names like "Switzerland", "Germany", "France", etc.

I try to come up with a codeline which updates the "country name" field with "0" if in the "registered country" field a pre-determined letter combination is found.

So as an example, in the field "Registered countries" there is the letter combination "CH, DE, SE, IE, GB, LU". The codeline is now supposed to recognize that there is the letter combo "DE" in the field and therefore put in the country name field "Germany" a "0".

What I have gotten so far is this:

strSQL = "UPDATE tblexample SET tblexample.[Germany] = ""0"" WHERE tblexample.[Registered Country] = ' *DE* '"

curdatabase.execute strSql, dbFailOnError

The problem is the "where-expression" is not right and I donīt manage to fix it. How is it possible to express that "DE" might be everywhere in the "Registered Country" field?

Thanks a lot for help!

Bob Phillips
02-09-2015, 12:52 PM
Try


strSQL = "UPDATE tblexample SET tblexample.[Germany] = ""0"" WHERE tblexample.[Registered Country] LIKE ' *DE* '"

linkerschuh
02-10-2015, 01:52 AM
Try


strSQL = "UPDATE tblexample SET tblexample.[Germany] = ""0"" WHERE tblexample.[Registered Country] LIKE ' *DE* '"

It doesn't work... For some reason it doesn't recognize the "*"s as variables.

Any idea how this could be solved?

Thanks a lot!

Bob Phillips
02-10-2015, 02:08 AM
Spaces crept in there


strSQL = "UPDATE tblexample SET tblexample.[Germany] = ""0"" WHERE tblexample.[Registered Country] LIKE '*DE*'"