473,416 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

How do I create an In-Statement in MS Access using records from a table?

My problem is as follows:

I need automatically iterate through a single field in a table and use
the values in the field to create an in-statement. Currently, the
character limitation in the "Zoom" feature of the MS Access query
builder limits the number of characters I can enter into my
In-Statement. As a result, I need to iterate through a particular
field (Customer ID Numbers) and use each record as a criteria in a
query. I want to be able to:
Step 1: Starting at record #1, create an in-statement for records 1-50
Step 2: For records 51-100, execute the same query and append the results to the table previously created in step 1.
Step 3: Without knowing how many records are in the table, iterate through the field each time running the same query and appending the results to the table created in step 1 in blocks of 50 and ending when the last record in the table is recognized.

Nov 12 '05 #1
3 13803
"Peter Phelps" <pp*****@ups.com> wrote in message
news:45**************************@posting.google.c om...
My problem is as follows:

I need automatically iterate through a single field in a table and use
the values in the field to create an in-statement. Currently, the
character limitation in the "Zoom" feature of the MS Access query
builder limits the number of characters I can enter into my
In-Statement. As a result, I need to iterate through a particular
field (Customer ID Numbers) and use each record as a criteria in a
query. I want to be able to:
Step 1: Starting at record #1, create an in-statement for records 1-50
Step 2: For records 51-100, execute the same query and append the results to the table previously created in step 1. Step 3: Without knowing how many records are in the table, iterate

through the field each time running the same query and appending the results
to the table created in step 1 in blocks of 50 and ending when the last
record in the table is recognized.

I can't tell whether this will be suitable for your situation, but instead
of building up a vast list of CusID numbers to be used in the IN clause,
have you considered using a sub-query?

SELECT CusID, CusCompany, CusAccountNo
FROM tblCustomers
WHERE CusID IN
(SELECT OrdCusID FROM tblOrders
WHERE OrdDate > #12/31/2002#)

The query above gives me in effect all the customer ID's for orders placed
this year. This beats going through the orders table and manually
extracting the CusID.
Could you use this, or had you already considered this?

Fletcher
Nov 12 '05 #2
I'm not 100% sure I'm following what you need, but I'll take a
guess.....you need to get 50 records at a time...if you add a new temp
field and:
1. init it to NULL
2.then select the top 50 where the new field is NULL - this will give
you the first 50
3. set the first 50 to some non-NULL char (such as 'Y')
This way you can select 50 recs at a time....

Perhaps what you're looking for is a way to compare records in a table
against themselves??? If so you can join a table to itself and compare
fields against each other - for example

Select a.*, b.*
From Table1 as a Left Join Table2 as b
On a.field1 = b.field1 and a.field2 <> b.field2.....etc.
pp*****@ups.com (Peter Phelps) wrote in message news:<45**************************@posting.google. com>...
My problem is as follows:

I need automatically iterate through a single field in a table and use
the values in the field to create an in-statement. Currently, the
character limitation in the "Zoom" feature of the MS Access query
builder limits the number of characters I can enter into my
In-Statement. As a result, I need to iterate through a particular
field (Customer ID Numbers) and use each record as a criteria in a
query. I want to be able to:
Step 1: Starting at record #1, create an in-statement for records 1-50
Step 2: For records 51-100, execute the same query and append the results to the table previously created in step 1.
Step 3: Without knowing how many records are in the table, iterate through the field each time running the same query and appending the results to the table created in step 1 in blocks of 50 and ending when the last record in the table is recognized.

Nov 12 '05 #3
pp*****@ups.com (Peter Phelps) wrote in
news:45**************************@posting.google.c om:
My problem is as follows:

I need automatically iterate through a single field in a table
and use the values in the field to create an in-statement.
Currently, the character limitation in the "Zoom" feature of
the MS Access query builder limits the number of characters I
can enter into my In-Statement.
Is what you REALLY want to create an in statement that contains all
the values of the field?
As a result, I need to iterate
through a particular field (Customer ID Numbers) and use each
record as a criteria in a query. I want to be able to:
If yes, simply use the following as the Criteria in your query:
IN (SELECT [Customer ID Numbers] from Table)
instead of typing each [Customer ID Numbers] into the Zoom box.

This gets around the limitation you face.

Bob Q.
Step 1: Starting at record #1, create an in-statement for
records 1-50 Step 2: For records 51-100, execute the same
query and append the results to the table previously created
in step 1. Step 3: Without knowing how many records are in
the table, iterate through the field each time running the
same query and appending the results to the table created in
step 1 in blocks of 50 and ending when the last record in the
table is recognized.


Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Daylor | last post by:
can i do it this way : from the defualt AppDomain : create thread. from the start function of the new thread , create new AppDomain,and then create my class through the AppDomain . this way...
2
by: Amil | last post by:
example: // form classes: // ItemEditor // CategoryEditor private void OpenForm(string formClassName) { // I want to be able to instantiate a form based on the parameter. if (formClassName...
9
by: Bob Achgill | last post by:
I would like to use the timestamp on files to manage the currency of support files for my VB windows application. In this case I would only put the timestamp of the file in the management database...
17
by: Jeffrey W. Baker | last post by:
Greetings, I have a 23GB data table upon which I am building a primary key of three columns. The data is mounted in a 137GB device and pg_xlog is mounted on a separate 3.5GB device. I have...
7
by: MarkoH | last post by:
Wsdl.exe /server creates abstract class derived from WebService. Is there a way to create this class at runtime based on some WSDL file given at runtime ? What would be even better - creating...
4
by: Jeff | last post by:
hey ASP.NET 2.0 I'm preparing for a certification exam on asp.net 2.0 and yesterday I took a skill assessment test on microsoft.com. One of the questions was about creating cookies. This was...
1
by: orenbt78 | last post by:
Hi, I am trying to: 1. Create a SQL database (I am working with SQL 2005 Express) 2. with a C# code 3. when the user is not the computer administrator. I have managed to create the database...
3
by: gillian3114 | last post by:
i got 3 type username and password : 1. boss 2. manager 3. staff how should i check if the username is exist then pop up msgbox error else add username and password to database
4
by: nano2k | last post by:
Hi For some purposes, I need to create a new binary file and to allocate a fixed length for that file on the disk. I need something like File.Create(string fileName, long initialSizeInBytes)....
1
by: Damodhar | last post by:
hi any one can help me to create the folder and sub folders for ex my project root is : test i want to create the folder like files/images/personal/profile/album/ damu i want to create...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.