473,387 Members | 1,749 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,387 software developers and data experts.

Access/ASP help displaying distinct Info

printedgoods
Hello all,

I have a table that has data about the t-shirts i sell. My goal is to display the colors that are available in a specific way on my asp page:

Shirt

I have been playing around for hours with this and need a 2nd opinion.


I am using the following query to get the data:
Expand|Select|Wrap|Line Numbers
  1. set color2RecordSet = Server.createObject("ADODB.RecordSet")
  2. color2Query = "SELECT DISTINCT product_shirts_colors_sizes.color, product_shirts_colors_sizes.hex, product_shirts_colors_sizes.size, product_shirts_colors_sizes.size FROM product_shirts_colors_sizes WHERE (((product_shirts_colors_sizes.size)='Youth Large' Or (product_shirts_colors_sizes.size)='Adult Large') AND ((product_shirts_colors_sizes.product_id)=" & Request.QueryString("product_id") & "))"  
  3.                 color2RecordSet.Open color2Query, dbConn, adOpenStatic, adLockReadOnly, adCmdText
  4.  
  5.  
And the following to display it:
Expand|Select|Wrap|Line Numbers
  1. <% while not  color2RecordSet.EOF  %>                    
  2. <% if  color2RecordSet.fields("size") = "Youth Large" then %>          
  3. <div style="padding:2px; padding-left:20px; height:30px; width:180px">
  4. <div style="height:30px; width:30px; float:left; background-color:#<%= color2RecordSet.fields("hex")%>"></div>
  5. <div style="height:25px; padding-left:10px; padding-top:5px; float:right; width:140px; color:#FF0000" ><%= color2RecordSet.fields("color")%></div>
  6. </div>
  7. <% else %>
  8. <div style="padding:2px; padding-left:20px; height:30px; width:180px">
  9. <div style="height:30px; width:30px; float:left; background-color:#<%= color2RecordSet.fields("hex")%>"></div>
  10. <div style="height:25px; padding-left:10px; padding-top:5px; float:right; width:140px" ><%= color2RecordSet.fields("color")%></div>
  11. </div> 
  12. <% end if%>     
  13. <% color2RecordSet.movenext  %>
  14. <% wend %>
  15.  
The problem is that not all colors are available in youth as seen in this image:






What i am trying to accomplish is pulling distinct colors and if it has youth sizes then display in red. If it dose not have youth sizes the display in black.

I hope i have explained enough... if not i can supply more info.

Thanks in advance
Nov 14 '07 #1
4 1293
jhardman
3,406 Expert 2GB
I am using the following query to get the data:
Expand|Select|Wrap|Line Numbers
  1. set color2RecordSet = Server.createObject("ADODB.RecordSet")
  2. color2Query = "SELECT DISTINCT product_shirts_colors_sizes.color, product_shirts_colors_sizes.hex, product_shirts_colors_sizes.size, product_shirts_colors_sizes.size FROM product_shirts_colors_sizes WHERE (((product_shirts_colors_sizes.size)='Youth Large' Or (product_shirts_colors_sizes.size)='Adult Large') AND ((product_shirts_colors_sizes.product_id)=" & Request.QueryString("product_id") & "))"  
  3.                 color2RecordSet.Open color2Query, dbConn, adOpenStatic, adLockReadOnly, adCmdText
  4.  
  5.  
When you are only pulling up info from one table, it is OK to shorten the name of the field to just the name of the field, you don't have to say tabelName.fieldName, just say fieldName:
Expand|Select|Wrap|Line Numbers
  1. color2Query = "SELECT DISTINCT color, hex, size FROM product_shirts_colors_sizes WHERE (((size)='Youth Large' Or (size)='Adult Large') AND ((product_id)=" & Request.QueryString("product_id") & "))"  
I know, it's a little thing, but I figure it helps, right?
And the following to display it:
So you are currently pulling up all the records where size equals "Youth Large" or "Adult Large", right? If the record you are displaying is "adult" then you print in black and if it is "youth" then you print in red. From the link it looks like this is working. Is it not?

Jared
Nov 17 '07 #2

So you are currently pulling up all the records where size equals "Youth Large" or "Adult Large", right? If the record you are displaying is "adult" then you print in black and if it is "youth" then you print in red. From the link it looks like this is working. Is it not?

Jared

Thanks for the reply Jared.

About the query, i was letting Access build it and you know how it loves to change the query to be like that with all the "{{[((" and stuff.....

It does display the query correctly. What i want to show (if possible to do in the query) is:

1) pull the data
2) If "youth" and "adult" show up for the same "color" then display in red
3) else -- if only "adult" then display in black


Thanks for your help

Jason
Nov 19 '07 #3
jhardman
3,406 Expert 2GB
Jason,

Are the only two possibilities that it is 1- only available in adult or 2- available in both adult or youth?

If that is right, I would add to the end of the query: " ORDER BY color ASC, size DESC", then when I loop through the records if the record is adult, I display in black and continue. If the record is youth, I display in red and skip the next record (it will be the same, but in adult) before I continue. Does this make sense? It might look something like this
Expand|Select|Wrap|Line Numbers
  1. do until RS.eof
  2.    if rs("size") = "Adult Large" then
  3.       'display in black, whatever your code looked like here
  4.    else
  5.       'display in red
  6.       RS.movenext
  7.    end if
  8.  
  9.    'whatever else you do per record
  10.    RS.movenext
  11. loop
Let me know if this helps.

Jared
Nov 19 '07 #4
thanks that worked like a charm. Check out the page now.

Now onto the next thing.......
Nov 21 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
5
by: Justin Fancy | last post by:
Hi everyone, I need some help. I'm placing text files into a created database using vb.Net. The problem is that, i need two seperate sql statements to add both files because they are in...
11
bhcob1
by: bhcob1 | last post by:
Hi, Whenever I delete a record my command button, the record deletes, a list displaying all records is updated and then a message box appears: Microsoft Access can't find the field 'I' referred to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.