Comparing user entered value to table value
Posted on 2011-09-08
How are you?
I have a table with 2 columns.
1st column contains cities and 2nd column contains provinces.
I want to store the province in a string called 'province' if the user entered city exists in the city column. I have the following code but not so familier with combining sql with vba.
Dim origin As String
Dim province as String
Dim rs As Recordset
origin = ocitytxt
I do want a sql formula which will find out the relative province based on city name and assign the province to province string
Something like this formula but I copied this from another example here...I know this is wrong :(
province = CurrentDb.OpenRecordset("SELECT origin FROM table1 WHERE (((city)=origin()));")
Thanks a million!