| Home | Forums | Reviews | Guides | Newsgroups | Register | Search |
![]() |
| Thread Tools |
| jason |
|
|
|
| |
|
Bob Barrows
Guest
Posts: n/a
|
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.createobject("adodb.recordset") 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 |
|
|
|
|
|||
|
|||
| Bob Barrows |
|
|
|
| |
|
jason
Guest
Posts: n/a
|
Hey Bob...this does not appear to solve the problem.....when 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.CustomerID, tblPageWatch.ListingsID AS ListingsID, qry_ListingsPriceChanges.NewPrice, qry_ListingsPriceChanges.Original_Price, qry_ListingsPriceChanges.Name, qry_ListingsPriceChanges.tblCompany.Company, qry_ListingsPriceChanges.Model, qry_ListingsPriceChanges.Size_ID, qry_ListingsPriceChanges.Hull_Number, qry_ListingsPriceChanges.Year, qry_ListingsPriceChanges.Location_Status, qry_ListingsPriceChanges.Yacht_Type, qry_ListingsPriceChanges.Market_Status, qry_ListingsPriceChanges.Charter_Status, qry_ListingsPriceChanges.Broker_Name, qry_ListingsPriceChanges.Broker_Email, tblCustomer.first_name, tblCustomer.last_name, tblCustomer.email_address, qry_ListingsPriceChanges.Condition, qry_ListingsPriceChanges.Insertion_Date FROM tblCustomer INNER JOIN (qry_ListingsPriceChanges INNER JOIN tblPageWatch ON qry_ListingsPriceChanges.tblListings.ListingsID = tblPageWatch.ListingsID) ON tblCustomer.CustomerID = tblPageWatch.CustomerID WHERE ((([CID]) Is Null)) OR (((tblCustomer.CustomerID)=[CID])) ORDER BY tblCustomer.CustomerID, tblPageWatch.ListingsID ; What am I doing wrong? Many thanks Jason "Bob Barrows" <> wrote in message news:... > 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.createobject("adodb.recordset") > 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 > > |
|
|
|
|
|||
|
|||
| jason |
|
Me
Guest
Posts: n/a
|
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.....when 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.CustomerID, tblPageWatch.ListingsID AS ListingsID, >qry_ListingsPriceChanges.NewPrice, qry_ListingsPriceChanges.Original_Price, >qry_ListingsPriceChanges.Name, qry_ListingsPriceChanges.tblCompany.Company, >qry_ListingsPriceChanges.Model, qry_ListingsPriceChanges.Size_ID, >qry_ListingsPriceChanges.Hull_Number, qry_ListingsPriceChanges.Year, >qry_ListingsPriceChanges.Location_Status, >qry_ListingsPriceChanges.Yacht_Type, qry_ListingsPriceChanges.Market_Status, >qry_ListingsPriceChanges.Charter_Status, >qry_ListingsPriceChanges.Broker_Name, qry_ListingsPriceChanges.Broker_Email, >tblCustomer.first_name, tblCustomer.last_name, tblCustomer.email_address, >qry_ListingsPriceChanges.Condition, qry_ListingsPriceChanges.Insertion_Date >FROM tblCustomer INNER JOIN (qry_ListingsPriceChanges INNER JOIN >tblPageWatch ON qry_ListingsPriceChanges.tblListings.ListingsID = >tblPageWatch.ListingsID) ON tblCustomer.CustomerID = tblPageWatch.CustomerID >WHERE ((([CID]) Is Null)) OR (((tblCustomer.CustomerID)= [CID])) >ORDER BY tblCustomer.CustomerID, tblPageWatch.ListingsID ; > >What am I doing wrong? > >Many thanks >Jason > > > > >"Bob Barrows" <> wrote in message >news:... >> 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.createobject("adodb.recordset") >> 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 >> >> > > >. > |
|
|
|
|
|||
|
|||
| Me |
|
jason
Guest
Posts: n/a
|
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> </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+PriceChanges] @CID=NULL,@LID=NULL" '//This '//------------------------------------------------------------------------- - set rs = cnn.execute(SQL) '//This 'open a connection using cn 'set rs = server.createobject("adodb.recordset") 'cnn.qGetCustInv 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> </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" <> wrote in message news:2752801c38f4d$564cbfb0$... > 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.....when 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.CustomerID, tblPageWatch.ListingsID AS > ListingsID, > >qry_ListingsPriceChanges.NewPrice, > qry_ListingsPriceChanges.Original_Price, > >qry_ListingsPriceChanges.Name, > qry_ListingsPriceChanges.tblCompany.Company, > >qry_ListingsPriceChanges.Model, > qry_ListingsPriceChanges.Size_ID, > >qry_ListingsPriceChanges.Hull_Number, > qry_ListingsPriceChanges.Year, > >qry_ListingsPriceChanges.Location_Status, > >qry_ListingsPriceChanges.Yacht_Type, > qry_ListingsPriceChanges.Market_Status, > >qry_ListingsPriceChanges.Charter_Status, > >qry_ListingsPriceChanges.Broker_Name, > qry_ListingsPriceChanges.Broker_Email, > >tblCustomer.first_name, tblCustomer.last_name, > tblCustomer.email_address, > >qry_ListingsPriceChanges.Condition, > qry_ListingsPriceChanges.Insertion_Date > >FROM tblCustomer INNER JOIN (qry_ListingsPriceChanges > INNER JOIN > >tblPageWatch ON > qry_ListingsPriceChanges.tblListings.ListingsID = > >tblPageWatch.ListingsID) ON tblCustomer.CustomerID = > tblPageWatch.CustomerID > >WHERE ((([CID]) Is Null)) OR (((tblCustomer.CustomerID)= > [CID])) > >ORDER BY tblCustomer.CustomerID, tblPageWatch.ListingsID ; > > > >What am I doing wrong? > > > >Many thanks > >Jason > > > > > > > > > >"Bob Barrows" <> wrote in message > >news:... > >> 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.createobject("adodb.recordset") > >> 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 > >> > >> > > > > > >. > > |
|
|
|
|
|||
|
|||
| jason |
|
Bob Barrows
Guest
Posts: n/a
|
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.createobject("adodb.recordset") > 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> </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 |
|
|
|
|
|||
|
|||
| Bob Barrows |
|
jason
Guest
Posts: n/a
|
Hi Bob - did you post it below....I cannot see your changes?
Thanks - Jason "Bob Barrows" <> wrote in message news:... > 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.createobject("adodb.recordset") > > 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> </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 > > |
|
|
|
|
|||
|
|||
| jason |
|
Bob Barrows
Guest
Posts: n/a
|
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" <> wrote in message > news:... >> 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.createobject("adodb.recordset") >>> 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> </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 |
|
|
|
|
|||
|
|||
| Bob Barrows |
|
jason
Guest
Posts: n/a
|
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+PriceChanges] @CID=NULL,@LID=NULL" '//This '//------------------------------------------------------------------------- - '//This 'open a connection using cn set rs = server.createobject("adodb.recordset") 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> </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" <> wrote in message news:... > 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" <> wrote in message > > news:... > >> 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.createobject("adodb.recordset") > >>> 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> </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 > > |
|
|
|
|
|||
|
|||
| jason |
|
Bob Barrows
Guest
Posts: n/a
|
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+PriceChanges] @CID=NULL,@LID=NULL" '//This > '//------------------------------------------------------------------------- > - > '//This > > > > > > 'open a connection using cn > set rs = server.createobject("adodb.recordset") > 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> </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" <> wrote in message > news:... >> 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" <> wrote in message >>> news:... >>>> 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.createobject("adodb.recordset") >>>>> 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> </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 |
|
|
|
|
|||
|
|||
| Bob Barrows |
|
|
|
| |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Triple nested loop python (While loop insde of for loop inside ofwhile loop) | Isaac Won | Python | 9 | 03-04-2013 10:08 AM |
| dicts,instances,containers, slotted instances, et cetera. | ocschwar@gmail.com | Python | 8 | 01-29-2009 09:52 AM |
| Amazon Low Price Leader DVD One Link Inventory To All DVDs | solipsistic@earthlink.net | DVD Video | 2 | 12-04-2004 05:23 PM |
| list of class instances within a list of a class instances | John Wohlbier | Python | 2 | 02-22-2004 08:41 AM |
| Custom controls instance problem on PostBack - two controls, one instance ??? | Dejan Vesic | ASP .Net Web Controls | 0 | 08-20-2003 02:43 PM |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc..
SEO by vBSEO ©2010, Crawlability, Inc. |




