Solved

VBA lookup to see if a record exists

Posted on 2013-02-03
2
233 Views
Last Modified: 2013-02-04
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.
0
Comment
Question by:rrudolph
2 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
Could you not do all in one single query?
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
Comment Utility
Follow on with..

Solditems.findfirst "solditems= '" & ItemsStr & "'"
if not solditems.Nomatch then
' at least one item found
else
' no items found
End if
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now