troubleshooting Question

Comparing user entered value to table value

Avatar of Shanan212
Shanan212Flag for Canada asked on
DatabasesMicrosoft AccessMicrosoft Applications
5 Comments1 Solution567 ViewsLast Modified:

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!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros