473,597 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Loop Cust-Ivent - need one instance of customer and many instances of inventory

Access 2000:

I have a customer-inventory table I need to loop through and compile a list
of all the inventory items the customer is tracking. The problem I am
finding is that a simple loop will pull out the customer details each time
their is an inventory item listed....I need to get the customer out ONCE and
list his items....is there an elegant way to do this:

Here is the table:
Cust-Invent Table

CustID InvenID
101 356
101 222
101 187
55 34
55 123
But I need to get the extract it to my ASP page like this:

101
----
356
222
187

55
---
34
123

If I simply loop the table I will repeat the customer details which I do not
want want. I just want to get the CustID and then list the inventory items
underneath (and send an email to him) and then rs.movenext to the next
record....

I really appreciate any help here...
Jason
Jul 19 '05 #1
12 2391
1. Create this saved query called qGetCustInv in your Access database:
Select CustID,InventID FROM Cust-Invent
ORDER BY CustID,InventID

2. In your asp page:
<%
dim cn, rs, ar, iRow, curCust, newCust
'open a connection using cn
set rs = server.createob ject("adodb.rec ordset")
cn.qGetCustInv rs
if not rs.eof then ar = rs.GetRows
rs.close: set rs = nothing
cn.close: set cn = nothing
if isarray(ar) then
curCust = ar(0,0)
response.write "<table border=0>"
For iRow = 0 to ubound(ar,2)
newCust = ar(0,i)
if newCust <> curCust then
curCust = newCust
response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"
end if
response.write "<tr><td>&nbsp; </td><td>"
response.write ar(1,i)
response.write "</td></tr>"
next
response.write "</table>"
erase ar
else
response.write "No records"
end if

HTH,
Bob Barrows

jason wrote:
Access 2000:

I have a customer-inventory table I need to loop through and compile
a list of all the inventory items the customer is tracking. The
problem I am finding is that a simple loop will pull out the customer
details each time their is an inventory item listed....I need to get
the customer out ONCE and list his items....is there an elegant way
to do this:

Here is the table:
Cust-Invent Table

CustID InvenID
101 356
101 222
101 187
55 34
55 123
But I need to get the extract it to my ASP page like this:

101
----
356
222
187

55
---
34
123

If I simply loop the table I will repeat the customer details which I
do not want want. I just want to get the CustID and then list the
inventory items underneath (and send an email to him) and then
rs.movenext to the next record....

I really appreciate any help here...
Jason

Jul 19 '05 #2
Hey Bob...this does not appear to solve the problem.....whe n I run your
script for my query I get the following and only the following for the first
customer in the query:

101 (hidden)

356
356
356

Thus, it appears to be finding the first customer record and listing the
yacht attached to that customer 3 times (matching the record count for all
the records in my table). It ignores the 2 other customer records and their
yacht inventory items.

I followed your general instructions for my existing query which is slightly
more complex but nevertheless should work:

PARAMETERS CID Long;
SELECT tblCustomer.Cus tomerID, tblPageWatch.Li stingsID AS ListingsID,
qry_ListingsPri ceChanges.NewPr ice, qry_ListingsPri ceChanges.Origi nal_Price,
qry_ListingsPri ceChanges.Name, qry_ListingsPri ceChanges.tblCo mpany.Company,
qry_ListingsPri ceChanges.Model , qry_ListingsPri ceChanges.Size_ ID,
qry_ListingsPri ceChanges.Hull_ Number, qry_ListingsPri ceChanges.Year,
qry_ListingsPri ceChanges.Locat ion_Status,
qry_ListingsPri ceChanges.Yacht _Type, qry_ListingsPri ceChanges.Marke t_Status,
qry_ListingsPri ceChanges.Chart er_Status,
qry_ListingsPri ceChanges.Broke r_Name, qry_ListingsPri ceChanges.Broke r_Email,
tblCustomer.fir st_name, tblCustomer.las t_name, tblCustomer.ema il_address,
qry_ListingsPri ceChanges.Condi tion, qry_ListingsPri ceChanges.Inser tion_Date
FROM tblCustomer INNER JOIN (qry_ListingsPr iceChanges INNER JOIN
tblPageWatch ON qry_ListingsPri ceChanges.tblLi stings.Listings ID =
tblPageWatch.Li stingsID) ON tblCustomer.Cus tomerID = tblPageWatch.Cu stomerID
WHERE ((([CID]) Is Null)) OR (((tblCustomer. CustomerID)=[CID]))
ORDER BY tblCustomer.Cus tomerID, tblPageWatch.Li stingsID ;

What am I doing wrong?

Many thanks
Jason


"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
news:OI******** ******@TK2MSFTN GP09.phx.gbl...
1. Create this saved query called qGetCustInv in your Access database:
Select CustID,InventID FROM Cust-Invent
ORDER BY CustID,InventID

2. In your asp page:
<%
dim cn, rs, ar, iRow, curCust, newCust
'open a connection using cn
set rs = server.createob ject("adodb.rec ordset")
cn.qGetCustInv rs
if not rs.eof then ar = rs.GetRows
rs.close: set rs = nothing
cn.close: set cn = nothing
if isarray(ar) then
curCust = ar(0,0)
response.write "<table border=0>"
For iRow = 0 to ubound(ar,2)
newCust = ar(0,i)
if newCust <> curCust then
curCust = newCust
response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"
end if
response.write "<tr><td>&nbsp; </td><td>"
response.write ar(1,i)
response.write "</td></tr>"
next
response.write "</table>"
erase ar
else
response.write "No records"
end if

HTH,
Bob Barrows

jason wrote:
Access 2000:

I have a customer-inventory table I need to loop through and compile
a list of all the inventory items the customer is tracking. The
problem I am finding is that a simple loop will pull out the customer
details each time their is an inventory item listed....I need to get
the customer out ONCE and list his items....is there an elegant way
to do this:

Here is the table:
Cust-Invent Table

CustID InvenID
101 356
101 222
101 187
55 34
55 123
But I need to get the extract it to my ASP page like this:

101
----
356
222
187

55
---
34
123

If I simply loop the table I will repeat the customer details which I
do not want want. I just want to get the CustID and then list the
inventory items underneath (and send an email to him) and then
rs.movenext to the next record....

I really appreciate any help here...
Jason


Jul 19 '05 #3
Me
I would use this as a reference
(http://aspfaq.com/show.asp?id=2241), it does what you are
looking for but uses 2 tables opposed to 1. The key is
setting a variable to nothing, reading the first record,
comparing the variable to the first records variable, if
not matched, move new value to the variable, write out the
101 the write out the details, if it is matched, just
write out the details. I hope that helps.

-----Original Message-----
Hey Bob...this does not appear to solve the problem.....whe n I run yourscript for my query I get the following and only the following for the firstcustomer in the query:

101 (hidden)

356
356
356

Thus, it appears to be finding the first customer record and listing theyacht attached to that customer 3 times (matching the record count for allthe records in my table). It ignores the 2 other customer records and theiryacht inventory items.

I followed your general instructions for my existing query which is slightlymore complex but nevertheless should work:

PARAMETERS CID Long;
SELECT tblCustomer.Cus tomerID, tblPageWatch.Li stingsID AS ListingsID,qry_ListingsPr iceChanges.NewP rice, qry_ListingsPri ceChanges.Origi nal_Price,qry_ListingsPr iceChanges.Name , qry_ListingsPri ceChanges.tblCo mpany.Company,qry_ListingsPr iceChanges.Mode l, qry_ListingsPri ceChanges.Size_ ID,qry_ListingsPr iceChanges.Hull _Number, qry_ListingsPri ceChanges.Year,qry_ListingsPr iceChanges.Loca tion_Status,
qry_ListingsPr iceChanges.Yach t_Type, qry_ListingsPri ceChanges.Marke t_Status,qry_ListingsPr iceChanges.Char ter_Status,
qry_ListingsPr iceChanges.Brok er_Name, qry_ListingsPri ceChanges.Broke r_Email,tblCustomer.fi rst_name, tblCustomer.las t_name, tblCustomer.ema il_address,qry_ListingsPr iceChanges.Cond ition, qry_ListingsPri ceChanges.Inser tion_DateFROM tblCustomer INNER JOIN (qry_ListingsPr iceChanges INNER JOINtblPageWatch ON qry_ListingsPri ceChanges.tblLi stings.Listings ID =tblPageWatch.L istingsID) ON tblCustomer.Cus tomerID = tblPageWatch.Cu stomerIDWHERE ((([CID]) Is Null)) OR (((tblCustomer. CustomerID)= [CID]))ORDER BY tblCustomer.Cus tomerID, tblPageWatch.Li stingsID ;

What am I doing wrong?

Many thanks
Jason


"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
news:OI******* *******@TK2MSFT NGP09.phx.gbl.. .
1. Create this saved query called qGetCustInv in your Access database: Select CustID,InventID FROM Cust-Invent
ORDER BY CustID,InventID

2. In your asp page:
<%
dim cn, rs, ar, iRow, curCust, newCust
'open a connection using cn
set rs = server.createob ject("adodb.rec ordset")
cn.qGetCustInv rs
if not rs.eof then ar = rs.GetRows
rs.close: set rs = nothing
cn.close: set cn = nothing
if isarray(ar) then
curCust = ar(0,0)
response.write "<table border=0>"
For iRow = 0 to ubound(ar,2)
newCust = ar(0,i)
if newCust <> curCust then
curCust = newCust
response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"
end if
response.write "<tr><td> </td><td>"
response.write ar(1,i)
response.write "</td></tr>"
next
response.write "</table>"
erase ar
else
response.write "No records"
end if

HTH,
Bob Barrows

jason wrote:
> Access 2000:
>
> I have a customer-inventory table I need to loop through and compile > a list of all the inventory items the customer is tracking. The > problem I am finding is that a simple loop will pull out the customer > details each time their is an inventory item listed....I need to get > the customer out ONCE and list his items....is there an elegant way > to do this:
>
> Here is the table:
> Cust-Invent Table
>
> CustID InvenID
> 101 356
> 101 222
> 101 187
> 55 34
> 55 123
>
>
> But I need to get the extract it to my ASP page like this: >
> 101
> ----
> 356
> 222
> 187
>
> 55
> ---
> 34
> 123
>
> If I simply loop the table I will repeat the customer details which I > do not want want. I just want to get the CustID and then list the > inventory items underneath (and send an email to him) and then > rs.movenext to the next record....
>
> I really appreciate any help here...
> Jason


.

Jul 19 '05 #4
Thanks - but this is not helping.... I have already optimized my structure
by employing a complex join in the jet engine...... I am not really sure
how to re-adapt my db and asp code to fit that model...

I mean, I have the damn Cust ID and Inventory ID already in my query...there
has just got to be a way to make sure the Customer ID (and related customer
info fields in query) show up ONCE with multiple inventory items listed....

Can someone help me get my head around this...Bobs suggestion seems to fall
short....I cannot pinpoint where the script if flawed as I am no array
expert. It appears that If I take this section and place it outside the For
Loop I end up with one inventory item as oppossed to 3 repeats:

response.write "<tr><td>&nbsp; </td><td>"
response.write ar(1,i) & " + " & ar(4,i)
response.write "</td></tr>"
response.write "</table>"

But, I am at a loss as to how to get the script to loop for the individual
customer and show just the boats related to him. Full code:

dim cnn, rs, ar, iRow, curCust, newCust
cnn.Open strCon
'//------------------------------ PAGEWATCH
SQL -------------------------------
SQL="EXEC [qry_PageWatch+P riceChanges] @CID=NULL,@LID= NULL" '//This
'//-------------------------------------------------------------------------
-
set rs = cnn.execute(SQL ) '//This

'open a connection using cn
'set rs = server.createob ject("adodb.rec ordset")
'cnn.qGetCustIn v rs

if not rs.eof then ar = rs.GetRows
rs.close: set rs = nothing
cnn.close: set cn = nothing
if isarray(ar) then
curCust = ar(0,0)
Response.Write curCust
response.write "<table border=0>"
' b=0
For iRow = 0 to ubound(ar,2)
' b=b+1
'Response.Write b
newCust = ar(0,i)
if newCust <> curCust then
curCust = newCust
response.write "<tr><td colspan=2>"
response.write curCust & "hi"
response.write "</td></tr>"
end if
'//Response.Write "hi"
next
response.write "<tr><td>&nbsp; </td><td>"
response.write ar(1,i) & " + " & ar(4,i)
response.write "</td></tr>"
response.write "</table>"
erase ar
else
response.write "No records"
end if

"Me" <no**@none.co m> wrote in message
news:27******** *************** ******@phx.gbl. ..
I would use this as a reference
(http://aspfaq.com/show.asp?id=2241), it does what you are
looking for but uses 2 tables opposed to 1. The key is
setting a variable to nothing, reading the first record,
comparing the variable to the first records variable, if
not matched, move new value to the variable, write out the
101 the write out the details, if it is matched, just
write out the details. I hope that helps.

-----Original Message-----
Hey Bob...this does not appear to solve the

problem.....whe n I run your
script for my query I get the following and only the

following for the first
customer in the query:

101 (hidden)

356
356
356

Thus, it appears to be finding the first customer record

and listing the
yacht attached to that customer 3 times (matching the

record count for all
the records in my table). It ignores the 2 other customer

records and their
yacht inventory items.

I followed your general instructions for my existing

query which is slightly
more complex but nevertheless should work:

PARAMETERS CID Long;
SELECT tblCustomer.Cus tomerID, tblPageWatch.Li stingsID AS

ListingsID,
qry_ListingsPr iceChanges.NewP rice,

qry_ListingsPri ceChanges.Origi nal_Price,
qry_ListingsPr iceChanges.Name ,

qry_ListingsPri ceChanges.tblCo mpany.Company,
qry_ListingsPr iceChanges.Mode l,

qry_ListingsPri ceChanges.Size_ ID,
qry_ListingsPr iceChanges.Hull _Number,

qry_ListingsPri ceChanges.Year,
qry_ListingsPr iceChanges.Loca tion_Status,
qry_ListingsPr iceChanges.Yach t_Type,

qry_ListingsPri ceChanges.Marke t_Status,
qry_ListingsPr iceChanges.Char ter_Status,
qry_ListingsPr iceChanges.Brok er_Name,

qry_ListingsPri ceChanges.Broke r_Email,
tblCustomer.fi rst_name, tblCustomer.las t_name,

tblCustomer.ema il_address,
qry_ListingsPr iceChanges.Cond ition,

qry_ListingsPri ceChanges.Inser tion_Date
FROM tblCustomer INNER JOIN (qry_ListingsPr iceChanges

INNER JOIN
tblPageWatch ON

qry_ListingsPri ceChanges.tblLi stings.Listings ID =
tblPageWatch.L istingsID) ON tblCustomer.Cus tomerID =

tblPageWatch.Cu stomerID
WHERE ((([CID]) Is Null)) OR (((tblCustomer. CustomerID)=

[CID]))
ORDER BY tblCustomer.Cus tomerID, tblPageWatch.Li stingsID ;

What am I doing wrong?

Many thanks
Jason


"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
news:OI******* *******@TK2MSFT NGP09.phx.gbl.. .
1. Create this saved query called qGetCustInv in your Access database: Select CustID,InventID FROM Cust-Invent
ORDER BY CustID,InventID

2. In your asp page:
<%
dim cn, rs, ar, iRow, curCust, newCust
'open a connection using cn
set rs = server.createob ject("adodb.rec ordset")
cn.qGetCustInv rs
if not rs.eof then ar = rs.GetRows
rs.close: set rs = nothing
cn.close: set cn = nothing
if isarray(ar) then
curCust = ar(0,0)
response.write "<table border=0>"
For iRow = 0 to ubound(ar,2)
newCust = ar(0,i)
if newCust <> curCust then
curCust = newCust
response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"
end if
response.write "<tr><td> </td><td>"
response.write ar(1,i)
response.write "</td></tr>"
next
response.write "</table>"
erase ar
else
response.write "No records"
end if

HTH,
Bob Barrows

jason wrote:
> Access 2000:
>
> I have a customer-inventory table I need to loop through and compile > a list of all the inventory items the customer is tracking. The > problem I am finding is that a simple loop will pull out the customer > details each time their is an inventory item listed....I need to get > the customer out ONCE and list his items....is there an elegant way > to do this:
>
> Here is the table:
> Cust-Invent Table
>
> CustID InvenID
> 101 356
> 101 222
> 101 187
> 55 34
> 55 123
>
>
> But I need to get the extract it to my ASP page like this: >
> 101
> ----
> 356
> 222
> 187
>
> 55
> ---
> 34
> 123
>
> If I simply loop the table I will repeat the customer details which I > do not want want. I just want to get the CustID and then list the > inventory items underneath (and send an email to him) and then > rs.movenext to the next record....
>
> I really appreciate any help here...
> Jason

.

Jul 19 '05 #5
See below for error correction:
Bob Barrows wrote:
1. Create this saved query called qGetCustInv in your Access database:
Select CustID,InventID FROM Cust-Invent
ORDER BY CustID,InventID

2. In your asp page:
<%
dim cn, rs, ar, iRow, curCust, newCust
'open a connection using cn
set rs = server.createob ject("adodb.rec ordset")
cn.qGetCustInv rs
if not rs.eof then ar = rs.GetRows
rs.close: set rs = nothing
cn.close: set cn = nothing
if isarray(ar) then
curCust = ar(0,0)
response.write "<table border=0>" response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>" For iRow = 0 to ubound(ar,2)
newCust = ar(0,i)
if newCust <> curCust then
curCust = newCust
response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"
end if
response.write "<tr><td>&nbsp; </td><td>"
response.write ar(1,i)
response.write "</td></tr>"
next
response.write "</table>"
erase ar
else
response.write "No records"
end if

HTH,
Bob Barrows

jason wrote:
Access 2000:

I have a customer-inventory table I need to loop through and compile
a list of all the inventory items the customer is tracking. The
problem I am finding is that a simple loop will pull out the customer
details each time their is an inventory item listed....I need to get
the customer out ONCE and list his items....is there an elegant way
to do this:

Here is the table:
Cust-Invent Table

CustID InvenID
101 356
101 222
101 187
55 34
55 123
But I need to get the extract it to my ASP page like this:

101
----
356
222
187

55
---
34
123

If I simply loop the table I will repeat the customer details which I
do not want want. I just want to get the CustID and then list the
inventory items underneath (and send an email to him) and then
rs.movenext to the next record....

I really appreciate any help here...
Jason

Jul 19 '05 #6
Hi Bob - did you post it below....I cannot see your changes?

Thanks - Jason
"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
news:ek******** ******@TK2MSFTN GP11.phx.gbl...
See below for error correction:
Bob Barrows wrote:
1. Create this saved query called qGetCustInv in your Access database:
Select CustID,InventID FROM Cust-Invent
ORDER BY CustID,InventID

2. In your asp page:
<%
dim cn, rs, ar, iRow, curCust, newCust
'open a connection using cn
set rs = server.createob ject("adodb.rec ordset")
cn.qGetCustInv rs
if not rs.eof then ar = rs.GetRows
rs.close: set rs = nothing
cn.close: set cn = nothing
if isarray(ar) then
curCust = ar(0,0)
response.write "<table border=0>"

response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"
For iRow = 0 to ubound(ar,2)
newCust = ar(0,i)
if newCust <> curCust then
curCust = newCust
response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"
end if
response.write "<tr><td>&nbsp; </td><td>"
response.write ar(1,i)
response.write "</td></tr>"
next
response.write "</table>"
erase ar
else
response.write "No records"
end if

HTH,
Bob Barrows

jason wrote:
Access 2000:

I have a customer-inventory table I need to loop through and compile
a list of all the inventory items the customer is tracking. The
problem I am finding is that a simple loop will pull out the customer
details each time their is an inventory item listed....I need to get
the customer out ONCE and list his items....is there an elegant way
to do this:

Here is the table:
Cust-Invent Table

CustID InvenID
101 356
101 222
101 187
55 34
55 123
But I need to get the extract it to my ASP page like this:

101
----
356
222
187

55
---
34
123

If I simply loop the table I will repeat the customer details which I
do not want want. I just want to get the CustID and then list the
inventory items underneath (and send an email to him) and then
rs.movenext to the next record....

I really appreciate any help here...
Jason


Jul 19 '05 #7
It's inline. Here: I'll mark it better:
jason wrote:
Hi Bob - did you post it below....I cannot see your changes?

Thanks - Jason
"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
news:ek******** ******@TK2MSFTN GP11.phx.gbl...
See below for error correction:
Bob Barrows wrote:
1. Create this saved query called qGetCustInv in your Access
database: Select CustID,InventID FROM Cust-Invent
ORDER BY CustID,InventID

2. In your asp page:
<%
dim cn, rs, ar, iRow, curCust, newCust
'open a connection using cn
set rs = server.createob ject("adodb.rec ordset")
cn.qGetCustInv rs
if not rs.eof then ar = rs.GetRows
rs.close: set rs = nothing
cn.close: set cn = nothing
if isarray(ar) then
curCust = ar(0,0)
response.write "<table border=0>" *************** *************** ***************
response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"


*************** *************** ******** For iRow = 0 to ubound(ar,2)
newCust = ar(0,i)
if newCust <> curCust then
curCust = newCust
response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"
end if
response.write "<tr><td>&nbsp; </td><td>"
response.write ar(1,i)
response.write "</td></tr>"
next
response.write "</table>"
erase ar
else
response.write "No records"
end if

HTH,
Bob Barrows

jason wrote:
Access 2000:

I have a customer-inventory table I need to loop through and
compile a list of all the inventory items the customer is
tracking. The problem I am finding is that a simple loop will
pull out the customer details each time their is an inventory item
listed....I need to get the customer out ONCE and list his
items....is there an elegant way to do this:

Here is the table:
Cust-Invent Table

CustID InvenID
101 356
101 222
101 187
55 34
55 123
But I need to get the extract it to my ASP page like this:

101
----
356
222
187

55
---
34
123

If I simply loop the table I will repeat the customer details
which I do not want want. I just want to get the CustID and then
list the inventory items underneath (and send an email to him) and
then rs.movenext to the next record....

I really appreciate any help here...
Jason

Jul 19 '05 #8
Hi Bob - no go - it still only:

1. Lists one customer
2. It repeats the first inventory item for that customer the same number of
times as the record count for the customers in the table. In this case,
three times.
3. It does not show the other inventory item related to this customer. It
comes out like this:

200 (CustomerID)
215 ("CatPeople" )
215 ("CatPeople" )
215 ("CatPeople" )

It does not show the other vessel listed for this customer: 216 ("Ballyhoo")

....And...

Its ignoring the next customer record: 201

...and its...related inventory item: 216 ("Ballyhoo")

- Jason

CODE:

dim cnn, rs, ar, iRow, curCust, newCust
cnn.Open strCon
'//------------------------------ PAGEWATCH
SQL -------------------------------
SQL="EXEC [qry_PageWatch+P riceChanges] @CID=NULL,@LID= NULL" '//This
'//-------------------------------------------------------------------------
-
'//This

'open a connection using cn
set rs = server.createob ject("adodb.rec ordset")
set rs = cnn.execute(sql )
if not rs.eof then ar = rs.GetRows
rs.close: set rs = nothing
cnn.close: set cnn = nothing
if isarray(ar) then
curCust = ar(0,0)
response.write "<table border=0>"
'//*************** *************** ***************

response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"

'//*************** *************** ********
For iRow = 0 to ubound(ar,2)
newCust = ar(0,i)
if newCust <> curCust then
curCust = newCust
response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"
end if
response.write "<tr><td>&nbsp; </td><td>"
response.write ar(1,i)
response.write "</td></tr>"
next
response.write "</table>"
erase ar
else
response.write "No records"
end if
"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
news:eC******** ******@TK2MSFTN GP12.phx.gbl...
It's inline. Here: I'll mark it better:
jason wrote:
Hi Bob - did you post it below....I cannot see your changes?

Thanks - Jason
"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
news:ek******** ******@TK2MSFTN GP11.phx.gbl...
See below for error correction:
Bob Barrows wrote:
1. Create this saved query called qGetCustInv in your Access
database: Select CustID,InventID FROM Cust-Invent
ORDER BY CustID,InventID

2. In your asp page:
<%
dim cn, rs, ar, iRow, curCust, newCust
'open a connection using cn
set rs = server.createob ject("adodb.rec ordset")
cn.qGetCustInv rs
if not rs.eof then ar = rs.GetRows
rs.close: set rs = nothing
cn.close: set cn = nothing
if isarray(ar) then
curCust = ar(0,0)
response.write "<table border=0>" *************** *************** ***************
response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"
*************** *************** ******** For iRow = 0 to ubound(ar,2)
newCust = ar(0,i)
if newCust <> curCust then
curCust = newCust
response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"
end if
response.write "<tr><td>&nbsp; </td><td>"
response.write ar(1,i)
response.write "</td></tr>"
next
response.write "</table>"
erase ar
else
response.write "No records"
end if

HTH,
Bob Barrows

jason wrote:
> Access 2000:
>
> I have a customer-inventory table I need to loop through and
> compile a list of all the inventory items the customer is
> tracking. The problem I am finding is that a simple loop will
> pull out the customer details each time their is an inventory item
> listed....I need to get the customer out ONCE and list his
> items....is there an elegant way to do this:
>
> Here is the table:
> Cust-Invent Table
>
> CustID InvenID
> 101 356
> 101 222
> 101 187
> 55 34
> 55 123
>
>
> But I need to get the extract it to my ASP page like this:
>
> 101
> ----
> 356
> 222
> 187
>
> 55
> ---
> 34
> 123
>
> If I simply loop the table I will repeat the customer details
> which I do not want want. I just want to get the CustID and then
> list the inventory items underneath (and send an email to him) and
> then rs.movenext to the next record....
>
> I really appreciate any help here...
> Jason


Jul 19 '05 #9
Damn! Change the i's to iRow. For example
newCust = ar(0,i)
should be
newCust = ar(0,iRow)

Bob

jason wrote:
Hi Bob - no go - it still only:

1. Lists one customer
2. It repeats the first inventory item for that customer the same
number of times as the record count for the customers in the table.
In this case, three times.
3. It does not show the other inventory item related to this
customer. It comes out like this:

200 (CustomerID)
215 ("CatPeople" )
215 ("CatPeople" )
215 ("CatPeople" )

It does not show the other vessel listed for this customer: 216
("Ballyhoo")

...And...

Its ignoring the next customer record: 201

..and its...related inventory item: 216 ("Ballyhoo")

- Jason

CODE:

dim cnn, rs, ar, iRow, curCust, newCust
cnn.Open strCon
'//------------------------------ PAGEWATCH
SQL -------------------------------
SQL="EXEC [qry_PageWatch+P riceChanges] @CID=NULL,@LID= NULL" '//This
'//------------------------------------------------------------------------- -
'//This

'open a connection using cn
set rs = server.createob ject("adodb.rec ordset")
set rs = cnn.execute(sql )
if not rs.eof then ar = rs.GetRows
rs.close: set rs = nothing
cnn.close: set cnn = nothing
if isarray(ar) then
curCust = ar(0,0)
response.write "<table border=0>"
'//*************** *************** ***************

response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"

'//*************** *************** ********
For iRow = 0 to ubound(ar,2)
newCust = ar(0,i)
if newCust <> curCust then
curCust = newCust
response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"
end if
response.write "<tr><td>&nbsp; </td><td>"
response.write ar(1,i)
response.write "</td></tr>"
next
response.write "</table>"
erase ar
else
response.write "No records"
end if
"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
news:eC******** ******@TK2MSFTN GP12.phx.gbl...
It's inline. Here: I'll mark it better:
jason wrote:
Hi Bob - did you post it below....I cannot see your changes?

Thanks - Jason
"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
news:ek******** ******@TK2MSFTN GP11.phx.gbl...
See below for error correction:
Bob Barrows wrote:
> 1. Create this saved query called qGetCustInv in your Access
> database: Select CustID,InventID FROM Cust-Invent
> ORDER BY CustID,InventID
>
> 2. In your asp page:
> <%
> dim cn, rs, ar, iRow, curCust, newCust
> 'open a connection using cn
> set rs = server.createob ject("adodb.rec ordset")
> cn.qGetCustInv rs
> if not rs.eof then ar = rs.GetRows
> rs.close: set rs = nothing
> cn.close: set cn = nothing
> if isarray(ar) then
> curCust = ar(0,0)
> response.write "<table border=0>"
> *************** *************** ***************

response.write "<tr><td colspan=2>"
response.write curCust
response.write "</td></tr>"


*************** *************** ********
> For iRow = 0 to ubound(ar,2)
> newCust = ar(0,i)
> if newCust <> curCust then
> curCust = newCust
> response.write "<tr><td colspan=2>"
> response.write curCust
> response.write "</td></tr>"
> end if
> response.write "<tr><td>&nbsp; </td><td>"
> response.write ar(1,i)
> response.write "</td></tr>"
> next
> response.write "</table>"
> erase ar
> else
> response.write "No records"
> end if
>
> HTH,
> Bob Barrows
>
> jason wrote:
>> Access 2000:
>>
>> I have a customer-inventory table I need to loop through and
>> compile a list of all the inventory items the customer is
>> tracking. The problem I am finding is that a simple loop will
>> pull out the customer details each time their is an inventory
>> item listed....I need to get the customer out ONCE and list his
>> items....is there an elegant way to do this:
>>
>> Here is the table:
>> Cust-Invent Table
>>
>> CustID InvenID
>> 101 356
>> 101 222
>> 101 187
>> 55 34
>> 55 123
>>
>>
>> But I need to get the extract it to my ASP page like this:
>>
>> 101
>> ----
>> 356
>> 222
>> 187
>>
>> 55
>> ---
>> 34
>> 123
>>
>> If I simply loop the table I will repeat the customer details
>> which I do not want want. I just want to get the CustID and then
>> list the inventory items underneath (and send an email to him)
>> and then rs.movenext to the next record....
>>
>> I really appreciate any help here...
>> Jason

Jul 19 '05 #10

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

Similar topics

0
2927
by: Charles Alexander | last post by:
Hello I am new to php & MySQL - I am trying to retrieve some records from a MySQL table and redisplay them. The data in list form looks like this: Sample_ID Marker_ID Variation G23_NA17192.fsa rs7374540 A/C I23_Control.fsa rs7374540 C/C
3
5256
by: Anand Pillai | last post by:
This is for folks who are familiar with asynchronous event handling in Python using the asyncore module. If you have ever used the asyncore module, you will realize that it's event loop does not have a programmable exit condition. It keeps looping till the channels in its socket map (a dictionary) are closed and don't have any pending reads/writes. If you are using Python threads in your application, by using either the threading or...
43
5564
by: Gremlin | last post by:
If you are not familiar with the halting problem, I will not go into it in detail but it states that it is impossible to write a program that can tell if a loop is infinite or not. This is a fallacy built on the assumption of mythical infinite all powerfull machines. In reality we deal with finite machines that are capable of two states in a loop, they either terminate, or repeat themselves. In the mythical halting problem scenario...
3
2659
by: Gustavo Randich | last post by:
The following seems to be a bug. The execution returns rows 1,2. It should return 1,1. In fact, if I run the code within a stored procedure alone (not in a trigger), the loop doesn't overwrite the value of y (works well). create table test (a integer) @ create table debug1 (a integer) @ create trigger test_1 after insert on test referencing new as ins for
5
7292
by: Martin Schou | last post by:
Please ignore the extreme simplicity of the task :-) I'm new to C, which explains why I'm doing an exercise like this. In the following tripple nested loop: int digit1 = 1; int digit2 = 0; int digit3 = 0; for( ; digit1 < 5 ; digit1++ ) {
32
4618
by: Toby Newman | last post by:
At the page: http://www.strath.ac.uk/IT/Docs/Ccourse/subsection3_8_3.html#SECTION0008300000000000000 or http://tinyurl.com/4ptzs the author warns: "The for loop is frequently used, usually where the loop will be traversed a fixed number of times. It is very flexible, and novice programmers should take care not to abuse the power it offers."
2
2672
by: Alex | last post by:
Compiler - Borland C++ 5.6.4 for Win32 Copyright (c) 1993, 2002 Borland Linker - Turbo Incremental Link 5.65 Copyright (c) 1997-2002 Borland Platform - Win32 (XP) Quite by accident I stumbled across some wierd loop behavior. With the pasted code I receive the output that follows. I realize that the code is broken, because the inner loop fails to reset j for each iteration of the outer loop (the fix is commented out). I also know that...
3
3513
by: Ben R. | last post by:
In an article I was reading (http://www.ftponline.com/vsm/2005_06/magazine/columns/desktopdeveloper/), I read the following: "The ending condition of a VB.NET for loop is evaluated only once, while the C# for loop ending condition is evaluated on every iteration." Is this accurate? I don't understand how you could get away without evaluating the ending condition at every iteration. Otherwise, how would you
32
2576
by: cj | last post by:
When I'm inside a do while loop sometimes it's necessary to jump out of the loop using exit do. I'm also used to being able to jump back and begin the loop again. Not sure which language my memories are of but I think I just said loop somewhere inside the loop and it immediately jumped back to the start of the loop and began again. I can't seem to do that in .net. I this functionality available?
2
19298
ADezii
by: ADezii | last post by:
If you are executing a code segment for a fixed number of iterations, always use a For...Next Loop instead of a Do...Loop, since it is significantly faster. Each pass through a Do...Loop that iterates a specified number of times, requires you to also implement or decrement some sort of Loop Counter, while a For...Next Loop does that work for you. Both Loops will provide the same results, but the For...Next Loop is substantially faster. One...
0
7969
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8272
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8381
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8258
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5847
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3886
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2404
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1494
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1238
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.