VBA loops

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Looking for proper syntax for a loop in a loop vba.

I have a table with Job information and another table related to it with
order information. I am looking for a way to loop through all jobs and then
list the orders for each job. I am actually going to print this info to an
email, here is an example of what I would like:



Job 100

Order 1 Order Desc
Order 2 Order Desc
Order 3 Order Desc



Thanks
 
Not knowing how you have the tables setup, but hopefully this will give you
some guidance.

The Jobs Table should have a primary key ("JobID") set as an autonumber.
The Order Table should have a primary key ("OrderID") set as an autonumber.
In the Order Table, add the "JobID" field, set as Number - Long Integer.
This field will be known as the foreign key to the Jobs Table.

Now that we have established the key fields, open the relationship (Tools ->
Relationships) and select both those tables. Create a link betwen the Jobs
Table (JobID field) to the Orders Table (JobID field). Now that we have
create the relationship, we can build a query that joins the two tables
together.

The end result is that the query will give you the basis to output the data
as you have specified below.

Let me know how you make out on this.

--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
Back
Top