discogs
asked on
How to use vba to update a field based on the value of another field?
Hi,
I have a field in a table named [Function] that contains what I believe a programmer would call a string.
It looks like the following with many variations:
--2-45--
1-34----
In a db, I added three additional fields named [ ShippingPort], [RailHub], [Airport].
How could I use vba to update each of these above fields based on the values within the [Function] field? i.e. If a 1 is found, then the corresponding [ShippingPort] field would be updated to Yes/No, if a 2 is found, then the corresponding [RailHub] field would be updated to Yes/No and so on.
Keys are as follows:
1 = Shipping Port
2 = Rail Hub
4 = Airport
Ideally, I would be able to run a procedure at any time that would update all the above three mentioned fields in my table, based on the contents of the string in the field [function].
I have enclosed a db file with the table as well if this helps.
Thanks
I have a field in a table named [Function] that contains what I believe a programmer would call a string.
It looks like the following with many variations:
--2-45--
1-34----
In a db, I added three additional fields named [ ShippingPort], [RailHub], [Airport].
How could I use vba to update each of these above fields based on the values within the [Function] field? i.e. If a 1 is found, then the corresponding [ShippingPort] field would be updated to Yes/No, if a 2 is found, then the corresponding [RailHub] field would be updated to Yes/No and so on.
Keys are as follows:
1 = Shipping Port
2 = Rail Hub
4 = Airport
Ideally, I would be able to run a procedure at any time that would update all the above three mentioned fields in my table, based on the contents of the string in the field [function].
I have enclosed a db file with the table as well if this helps.
Thanks
ASKER
Hi,
Thanks for your answer and sorry to not include the file. I am new here.
I have tried your proposed efforts with little joy and have enclosed the attachment with your suggested answer in it.
Ta
Database1.accdb
Thanks for your answer and sorry to not include the file. I am new here.
I have tried your proposed efforts with little joy and have enclosed the attachment with your suggested answer in it.
Ta
Database1.accdb
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. I had to tweak it a bit but got there in the end. Good work. Ta
Create a query instead similar to this:
Open in new window
Ron