Solved

VBA lookup to see if a record exists

Posted on 2013-02-03
2
247 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]
ID: 38848779
Could you not do all in one single query?
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 38848791
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

863 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

20 Experts available now in Live!

Get 1:1 Help Now