Using VBA, how can I search for a text string, for example “CHIR”, in a table called “ServiceYES”, in the field “Service”.
After that, I would like to save the neighboring field for all the rows that “CHIR” exists in the table “ServicesYES”. The “ServiceYES” table is below:

I basically, want to find all the “CHIR” in “Service” column and then save the names which are on the left of the CHIR, eg “FRANKL_L”, “SANTIA_D” as an array.
Thanks for all your help in advance.
Start by creating a
SELECTquery.Use
SELECT DISTINCT Code_Persoif you want only the unique values.Add
ORDER BY Code_Persoif you care to have them sorted alphabetically.Once you have a satisfactory query, open a DAO recordset based on that query, and loop through the
Code_Persovalues it returns.You don’t need to load them directly into your final array. It might be easier to add them to a comma-separated string. Afterward you can use the
Split()function (assuming you have Access version >= 2000) to create your array.Here’s sample code to get you started. It’s mostly standard boiler-plate, but it might actually work … once you give it “yourquery”.