I have some experience working with recordests via an ADOB connection in VBScript to pull data from an access table based on a criteria, but i haven’t worked with doing this internally on an Access db and, unfortunately, I need to use the LIKE operator to pull the necessary records from one table and, perhaps, make a new table based on the query. The other issue is I need to use another table as a look-up for the values being matched.
To be specific: I have a table of contact info with one column that lists a series of counties (one or more) comma-deliminated. I have another table with each county listed. Here is a working SQL string that can pull a given record from the contacts table based on a *SPECIFIC* value (passed from a drop-down box):
SQLstring = “SELECT * FROM LocalCRCGContacts where Categories LIKE ‘%” & County & “%’ ;”
My problem, and it is certainly very basic (but not so simple for me at the moment!) is to apply this code in Access to page thru a look-up table of County names and copy out every record in the contacts table where the LIKE condition finds a match. This would generate a recordset and that recordset could then be written to a table (one I’d probably create previously and refer in code). I’ll have several sub-queries eventually once I get the master code to function but I am not clear on how one does the following:
1) Open existing tables — this is what I have:
DoCmd.SelectObject acTable, “CNTYCODE”
DoCmd.SelectObject acTable, “LocalCRCGContacts”
2) Set up a loop tied to a recordset (or even more directly, open a third table and write matches from the LocalCRCGContacts based on the value of CNTYCODE). The problem here is, instead of passing one value, one pages thru the lookup table for every record in the contacts table and copy out a range of data.
3) Determine the fields written to the results table with the matched county written to the same record row as the matched record so that a multi-county record will be tagged to one county at a time.
This should all be fairly easy but i have gone thru a lot of the previous posts and haven’t found a clear enough example.
Thanks in advance for your help!!