Solved

VBA lookup to see if a record exists

Posted on 2013-02-03
2
256 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

810 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