So here's a fun question I would really appreciate some help on. The actually problem uses more complex data, but if anyone can help me solve the problem below, either with a VBA example or through querries, I would really appreciate it.
Okay, so:
Two tables:
Table 1
AgencyID Begin R End R
a1 1 100
a2 101 200
a3 201 300
Table 2
agencyID IdNum data 1 data 2…
33 bla bla
124 bla bla
222 bla bla
137 bla bla
12 bla bla
298 bla bla
Okay, so what I need to be able to do is take the two tables, compare the IdNum of the second table to the Range of the first table signified by BeginR and EndR, and if it is in a particular range, I need the agencyId field of the second table to inherit the agency id from the first table.
I have thousands of records, and a couple hundred ranges in real life, so I can't set up an if statement for each range of numbers without being there for a few weeks.
I was thinking something along the lines of an for loop that goes to each record in the database in the first table, but I don't understand enough about vba or for statements to get there. Any help or small examples would be greatly appreciated.
Okay, so:
Two tables:
Table 1
AgencyID Begin R End R
a1 1 100
a2 101 200
a3 201 300
Table 2
agencyID IdNum data 1 data 2…
33 bla bla
124 bla bla
222 bla bla
137 bla bla
12 bla bla
298 bla bla
Okay, so what I need to be able to do is take the two tables, compare the IdNum of the second table to the Range of the first table signified by BeginR and EndR, and if it is in a particular range, I need the agencyId field of the second table to inherit the agency id from the first table.
I have thousands of records, and a couple hundred ranges in real life, so I can't set up an if statement for each range of numbers without being there for a few weeks.
I was thinking something along the lines of an for loop that goes to each record in the database in the first table, but I don't understand enough about vba or for statements to get there. Any help or small examples would be greatly appreciated.