VBA lookup to see if a record exists
Posted on 2013-02-03
I have a master item table (Table1) with about 1500 records in it. I am looping through the records in this table and checking them against a much smaller record set I am creating. If the Itemstr field in table1 exists in any of the solditems fields of the record set, I want to perform some calculations, if not I want to exit the loop.
The record set is created with the following code, and this code seems to work fine.
ProstrSQL = "SELECT ActiveGroupItems.TYPE, ActiveGroupItems.ITEM_NUMBER AS SoldItems"
ProstrSQL = ProstrSQL & " FROM ActiveGroupItems"
ProstrSQL = ProstrSQL & " WHERE ActiveGroupItems.TYPE = " & "'" & CGName & "'"
Set SoldItems = CurrentDb.OpenRecordset(ProstrSQL)
I would like to check the ItemStr variable agains the recordset for the SoldItems field.