Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: table inside table


Message #1 by Ping Li <pli@l...> on Thu, 20 Dec 2001 13:31:08 -0600
Thanks, Ken, I will go back to my table and check the design. But I have

another problem that I wish you would give me a hint. I want to create a

table inside another table and display data in that cell according to

different conditions. I feel I am close but I just couldn't get it. I doubt

the expression "if RS("Company_ID") = varID then" doesn't work at all. Would

you or anybody please help me with this piece of code? I have stared at it

and testing page for two days without any success. Is my logic wrong? why

the "if RS("Company_ID") = varID then" statement doesn't compare two numbers

even when they are the same?



Thank you very much for your help. 

Ping



My codes:

=========

dim RS, output1, output2

varID = request.form("ID")



if not RS.eof then

   response.write	"<table>" & _

   "<tr>" &_

   "<th>Item </th>" &_

   "<th>Value </th>" &_

   "<th>Company</th>" &_

	do while not RS.eof

		output1 = "<tr><td>"

		output1 = output1 & RS("item")& "</td>"

 		output1 = output1 & "<td>" & RS("value") & "</td>"

		response.write output1 



 'HERE IS TO CREATE AND POPULATE TABLE INSIDE A CELL(But blank results)

=====================================================================

 		response.write "<td>" 

 				output2 = "<table><tr><td>" 

                        if RS("Company_ID") = varID then

					output2 = output2 & RS("company") &

"</td></tr>"

					blnFound = true

				end if

				if RS("Division_ID") = varID then

					output2 = output2 & RS("division") &

"</td></tr>"

					blnFound = true

				end if

				response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else 

	response.write "wrong number."

end if





			

-----Original Message-----

From: Ken Schaefer [mailto:ken@a...]

Sent: Tuesday, December 18, 2001 6:17 PM

To: Access ASP

Subject: [access_asp] Re: two-dimensional table display





This looks like bad table design, hence the problems you are having with

writing the queries.



What if you created a 2nd table which stored companies and divisions (call

this Units). Then you used a JOIN table to link the Item to the Unit, and

store their portion of the cost:



Table Items

Table Units

Table ItemsUnits (ItemID, UnitID, Cost)



Then it'd be easy to write a query joining these three tables together.



Cheers

Ken



Message #2 by "Scott Reed" <scottr@m...> on Thu, 20 Dec 2001 14:58:44 -0600
according to your code....



If neither case is true (Company_ID or Division_ID is not equal to varID)

then nothing will get written to page. Your "else" statment is outside of

those nested loops.



You may want to toss in an "else" between each of the nested loops that

writes the value of Company_ID, Division_ID and varID to the page during

each itteration so that you can manually compare the values.



Nothing in your code assigns a value to Compay_ID or Division_ID so I can

only assume that is being done.



-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 1:31 PM

To: Access ASP

Subject: [access_asp] table inside table

Importance: High





Thanks, Ken, I will go back to my table and check the design. But I have

another problem that I wish you would give me a hint. I want to create a

table inside another table and display data in that cell according to

different conditions. I feel I am close but I just couldn't get it. I doubt

the expression "if RS("Company_ID") = varID then" doesn't work at all. Would

you or anybody please help me with this piece of code? I have stared at it

and testing page for two days without any success. Is my logic wrong? why

the "if RS("Company_ID") = varID then" statement doesn't compare two numbers

even when they are the same?



Thank you very much for your help.

Ping



My codes:

=========

dim RS, output1, output2

varID = request.form("ID")



if not RS.eof then

   response.write	"<table>" & _

   "<tr>" &_

   "<th>Item </th>" &_

   "<th>Value </th>" &_

   "<th>Company</th>" &_

	do while not RS.eof

		output1 = "<tr><td>"

		output1 = output1 & RS("item")& "</td>"

 		output1 = output1 & "<td>" & RS("value") & "</td>"

		response.write output1



 'HERE IS TO CREATE AND POPULATE TABLE INSIDE A CELL(But blank results)

=====================================================================

 		response.write "<td>"

 				output2 = "<table><tr><td>"

                        if RS("Company_ID") = varID then

					output2 = output2 & RS("company") &

"</td></tr>"

					blnFound = true

				end if

				if RS("Division_ID") = varID then

					output2 = output2 & RS("division") &

"</td></tr>"

					blnFound = true

				end if

				response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "wrong number."

end if







-----Original Message-----

From: Ken Schaefer [mailto:ken@a...]

Sent: Tuesday, December 18, 2001 6:17 PM

To: Access ASP

Subject: [access_asp] Re: two-dimensional table display





This looks like bad table design, hence the problems you are having with

writing the queries.



What if you created a 2nd table which stored companies and divisions (call

this Units). Then you used a JOIN table to link the Item to the Unit, and

store their portion of the cost:



Table Items

Table Units

Table ItemsUnits (ItemID, UnitID, Cost)



Then it'd be easy to write a query joining these three tables together.



Cheers

Ken










Message #3 by Ping Li <pli@l...> on Thu, 20 Dec 2001 14:06:16 -0600
Scott, thanks for your email. Company_ID and Division_ID are fields of my

recordset RS. varID is user input. What's bugging me is that when I input

1234 as ID and 1234 is truely the company A's ID in my database. So it's

supposed to return company's name. But no, nothing return. When I followed

your suggestion and added "else response.write "not a Company"", it returned

"not a company". That means the computer thinks 1234(Company_ID in database)

doesn't equal to 1234(user input). Do you know what I mean? they are the

same number, but the computer thinks not. I just don't understand.

Company_ID is set to be number, is the user input default to be number?



Ping



-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 2:59 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





according to your code....



If neither case is true (Company_ID or Division_ID is not equal to varID)

then nothing will get written to page. Your "else" statment is outside of

those nested loops.



You may want to toss in an "else" between each of the nested loops that

writes the value of Company_ID, Division_ID and varID to the page during

each itteration so that you can manually compare the values.



Nothing in your code assigns a value to Compay_ID or Division_ID so I can

only assume that is being done.



-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 1:31 PM

To: Access ASP

Subject: [access_asp] table inside table

Importance: High





Thanks, Ken, I will go back to my table and check the design. But I have

another problem that I wish you would give me a hint. I want to create a

table inside another table and display data in that cell according to

different conditions. I feel I am close but I just couldn't get it. I doubt

the expression "if RS("Company_ID") = varID then" doesn't work at all. Would

you or anybody please help me with this piece of code? I have stared at it

and testing page for two days without any success. Is my logic wrong? why

the "if RS("Company_ID") = varID then" statement doesn't compare two numbers

even when they are the same?



Thank you very much for your help.

Ping



My codes:

=========

dim RS, output1, output2

varID = request.form("ID")



if not RS.eof then

   response.write	"<table>" & _

   "<tr>" &_

   "<th>Item </th>" &_

   "<th>Value </th>" &_

   "<th>Company</th>" &_

	do while not RS.eof

		output1 = "<tr><td>"

		output1 = output1 & RS("item")& "</td>"

 		output1 = output1 & "<td>" & RS("value") & "</td>"

		response.write output1



 'HERE IS TO CREATE AND POPULATE TABLE INSIDE A CELL(But blank results)

=====================================================================

 		response.write "<td>"

 				output2 = "<table><tr><td>"

                        if RS("Company_ID") = varID then

					output2 = output2 & RS("company") &

"</td></tr>"

					blnFound = true

				end if

				if RS("Division_ID") = varID then

					output2 = output2 & RS("division") &

"</td></tr>"

					blnFound = true

				end if

				response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "wrong number."

end if







-----Original Message-----

From: Ken Schaefer [mailto:ken@a...]

Sent: Tuesday, December 18, 2001 6:17 PM

To: Access ASP

Subject: [access_asp] Re: two-dimensional table display





This looks like bad table design, hence the problems you are having with

writing the queries.



What if you created a 2nd table which stored companies and divisions (call

this Units). Then you used a JOIN table to link the Item to the Unit, and

store their portion of the cost:



Table Items

Table Units

Table ItemsUnits (ItemID, UnitID, Cost)



Then it'd be easy to write a query joining these three tables together.



Cheers

Ken















Message #4 by "Scott Reed" <scottr@m...> on Thu, 20 Dec 2001 15:38:27 -0600
First, I suspect that the values are not what you think they are.

At the end of each loop, Response.Write each value to the page.

You will then be able to compare the values yourself.



Now, let's say that you assign the values manually (for testing's sake)



Dim varID

varID = "1234"

Dim Company_ID

Company_ID = "1234"



If Company_ID = varID Then

	Response.Write "BINGO"

Else

	Response.Write "FUBAR"

End If



If that case works but your other assignment of value does not,

make sure that the Variable "types" are the same and your not

comparing a String to an Integer(or whatever).In not entirely sure

but I think that field values collected from a form (user input)

are automatically stored as strings(?).



But again, the problem may be with the way this data is stored in

your database, they way you are retrieving the value or the way

your are storing the value. The first place to start is seeing what

is being returned for each item.



anyway, hope you figure it out...

Scott Reed





-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 2:06 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





Scott, thanks for your email. Company_ID and Division_ID are fields of my

recordset RS. varID is user input. What's bugging me is that when I input

1234 as ID and 1234 is truely the company A's ID in my database. So it's

supposed to return company's name. But no, nothing return. When I followed

your suggestion and added "else response.write "not a Company"", it returned

"not a company". That means the computer thinks 1234(Company_ID in database)

doesn't equal to 1234(user input). Do you know what I mean? they are the

same number, but the computer thinks not. I just don't understand.

Company_ID is set to be number, is the user input default to be number?



Ping



-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 2:59 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





according to your code....



If neither case is true (Company_ID or Division_ID is not equal to varID)

then nothing will get written to page. Your "else" statment is outside of

those nested loops.



You may want to toss in an "else" between each of the nested loops that

writes the value of Company_ID, Division_ID and varID to the page during

each itteration so that you can manually compare the values.



Nothing in your code assigns a value to Compay_ID or Division_ID so I can

only assume that is being done.



-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 1:31 PM

To: Access ASP

Subject: [access_asp] table inside table

Importance: High





Thanks, Ken, I will go back to my table and check the design. But I have

another problem that I wish you would give me a hint. I want to create a

table inside another table and display data in that cell according to

different conditions. I feel I am close but I just couldn't get it. I doubt

the expression "if RS("Company_ID") = varID then" doesn't work at all. Would

you or anybody please help me with this piece of code? I have stared at it

and testing page for two days without any success. Is my logic wrong? why

the "if RS("Company_ID") = varID then" statement doesn't compare two numbers

even when they are the same?



Thank you very much for your help.

Ping



My codes:

=========

dim RS, output1, output2

varID = request.form("ID")



if not RS.eof then

   response.write	"<table>" & _

   "<tr>" &_

   "<th>Item </th>" &_

   "<th>Value </th>" &_

   "<th>Company</th>" &_

	do while not RS.eof

		output1 = "<tr><td>"

		output1 = output1 & RS("item")& "</td>"

 		output1 = output1 & "<td>" & RS("value") & "</td>"

		response.write output1



 'HERE IS TO CREATE AND POPULATE TABLE INSIDE A CELL(But blank results)

=====================================================================

 		response.write "<td>"

 				output2 = "<table><tr><td>"

                        if RS("Company_ID") = varID then

					output2 = output2 & RS("company") &

"</td></tr>"

					blnFound = true

				end if

				if RS("Division_ID") = varID then

					output2 = output2 & RS("division") &

"</td></tr>"

					blnFound = true

				end if

				response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "wrong number."

end if







-----Original Message-----

From: Ken Schaefer [mailto:ken@a...]

Sent: Tuesday, December 18, 2001 6:17 PM

To: Access ASP

Subject: [access_asp] Re: two-dimensional table display





This looks like bad table design, hence the problems you are having with

writing the queries.



What if you created a 2nd table which stored companies and divisions (call

this Units). Then you used a JOIN table to link the Item to the Unit, and

store their portion of the cost:



Table Items

Table Units

Table ItemsUnits (ItemID, UnitID, Cost)



Then it'd be easy to write a query joining these three tables together.



Cheers

Ken






















Message #5 by Ping Li <pli@l...> on Thu, 20 Dec 2001 15:06:58 -0600
You were right, Scott, the user input data type isn't the same as that in my

database. When I use CLng(varID), data returned. But in the wrong order, the

division name comes first then company name. The intended order was company

name, then division's name. Can you think of a reason?



Thanks again for your help. Ping





response.write "<td>"

 	output2 = "<table><tr><td>"

      if RS("Company_ID") = varID then

		output2 = output2 & RS("company") & "</td></tr>"

		blnFound = true

		end if

'I missed blnFound part out of the second condition

===================================================

	if blnFound or RS("Division_ID") = varID then

		output2 = output2 & RS("division") & "</td></tr>"

		blnFound = true

		end if

response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "wrong number."

end if

-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 3:38 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





First, I suspect that the values are not what you think they are.

At the end of each loop, Response.Write each value to the page.

You will then be able to compare the values yourself.



Now, let's say that you assign the values manually (for testing's sake)



Dim varID

varID = "1234"

Dim Company_ID

Company_ID = "1234"



If Company_ID = varID Then

	Response.Write "BINGO"

Else

	Response.Write "FUBAR"

End If



If that case works but your other assignment of value does not,

make sure that the Variable "types" are the same and your not

comparing a String to an Integer(or whatever).In not entirely sure

but I think that field values collected from a form (user input)

are automatically stored as strings(?).



But again, the problem may be with the way this data is stored in

your database, they way you are retrieving the value or the way

your are storing the value. The first place to start is seeing what

is being returned for each item.



anyway, hope you figure it out...

Scott Reed





-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 2:06 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





Scott, thanks for your email. Company_ID and Division_ID are fields of my

recordset RS. varID is user input. What's bugging me is that when I input

1234 as ID and 1234 is truely the company A's ID in my database. So it's

supposed to return company's name. But no, nothing return. When I followed

your suggestion and added "else response.write "not a Company"", it returned

"not a company". That means the computer thinks 1234(Company_ID in database)

doesn't equal to 1234(user input). Do you know what I mean? they are the

same number, but the computer thinks not. I just don't understand.

Company_ID is set to be number, is the user input default to be number?



Ping



-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 2:59 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





according to your code....



If neither case is true (Company_ID or Division_ID is not equal to varID)

then nothing will get written to page. Your "else" statment is outside of

those nested loops.



You may want to toss in an "else" between each of the nested loops that

writes the value of Company_ID, Division_ID and varID to the page during

each itteration so that you can manually compare the values.



Nothing in your code assigns a value to Compay_ID or Division_ID so I can

only assume that is being done.



-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 1:31 PM

To: Access ASP

Subject: [access_asp] table inside table

Importance: High





Thanks, Ken, I will go back to my table and check the design. But I have

another problem that I wish you would give me a hint. I want to create a

table inside another table and display data in that cell according to

different conditions. I feel I am close but I just couldn't get it. I doubt

the expression "if RS("Company_ID") = varID then" doesn't work at all. Would

you or anybody please help me with this piece of code? I have stared at it

and testing page for two days without any success. Is my logic wrong? why

the "if RS("Company_ID") = varID then" statement doesn't compare two numbers

even when they are the same?



Thank you very much for your help.

Ping



My codes:

=========

dim RS, output1, output2

varID = request.form("ID")



if not RS.eof then

   response.write	"<table>" & _

   "<tr>" &_

   "<th>Item </th>" &_

   "<th>Value </th>" &_

   "<th>Company</th>" &_

	do while not RS.eof

		output1 = "<tr><td>"

		output1 = output1 & RS("item")& "</td>"

 		output1 = output1 & "<td>" & RS("value") & "</td>"

		response.write output1



 'HERE IS TO CREATE AND POPULATE TABLE INSIDE A CELL(But blank results)

=====================================================================

 		response.write "<td>"

 				output2 = "<table><tr><td>"

                        if RS("Company_ID") = varID then

					output2 = output2 & RS("company") &

"</td></tr>"

					blnFound = true

				end if

				if RS("Division_ID") = varID then

					output2 = output2 & RS("division") &

"</td></tr>"

					blnFound = true

				end if

				response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "wrong number."

end if





Message #6 by "Scott Reed" <scottr@m...> on Thu, 20 Dec 2001 16:23:44 -0600
blnFound has a boolean assignment so you really don't need that in your

second

conditional statement.



Not sure about the order of return, I would need to see more of your code. I

would,

however, suggest using a direct reference to the value...SQL("company).Value



Scott



-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 3:07 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





You were right, Scott, the user input data type isn't the same as that in my

database. When I use CLng(varID), data returned. But in the wrong order, the

division name comes first then company name. The intended order was company

name, then division's name. Can you think of a reason?



Thanks again for your help. Ping





response.write "<td>"

 	output2 = "<table><tr><td>"

      if RS("Company_ID") = varID then

		output2 = output2 & RS("company") & "</td></tr>"

		blnFound = true

		end if

'I missed blnFound part out of the second condition

===================================================

	if blnFound or RS("Division_ID") = varID then

		output2 = output2 & RS("division") & "</td></tr>"

		blnFound = true

		end if

response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "wrong number."

end if

-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 3:38 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





First, I suspect that the values are not what you think they are.

At the end of each loop, Response.Write each value to the page.

You will then be able to compare the values yourself.



Now, let's say that you assign the values manually (for testing's sake)



Dim varID

varID = "1234"

Dim Company_ID

Company_ID = "1234"



If Company_ID = varID Then

	Response.Write "BINGO"

Else

	Response.Write "FUBAR"

End If



If that case works but your other assignment of value does not,

make sure that the Variable "types" are the same and your not

comparing a String to an Integer(or whatever).In not entirely sure

but I think that field values collected from a form (user input)

are automatically stored as strings(?).



But again, the problem may be with the way this data is stored in

your database, they way you are retrieving the value or the way

your are storing the value. The first place to start is seeing what

is being returned for each item.



anyway, hope you figure it out...

Scott Reed





-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 2:06 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





Scott, thanks for your email. Company_ID and Division_ID are fields of my

recordset RS. varID is user input. What's bugging me is that when I input

1234 as ID and 1234 is truely the company A's ID in my database. So it's

supposed to return company's name. But no, nothing return. When I followed

your suggestion and added "else response.write "not a Company"", it returned

"not a company". That means the computer thinks 1234(Company_ID in database)

doesn't equal to 1234(user input). Do you know what I mean? they are the

same number, but the computer thinks not. I just don't understand.

Company_ID is set to be number, is the user input default to be number?



Ping



-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 2:59 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





according to your code....



If neither case is true (Company_ID or Division_ID is not equal to varID)

then nothing will get written to page. Your "else" statment is outside of

those nested loops.



You may want to toss in an "else" between each of the nested loops that

writes the value of Company_ID, Division_ID and varID to the page during

each itteration so that you can manually compare the values.



Nothing in your code assigns a value to Compay_ID or Division_ID so I can

only assume that is being done.



-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 1:31 PM

To: Access ASP

Subject: [access_asp] table inside table

Importance: High





Thanks, Ken, I will go back to my table and check the design. But I have

another problem that I wish you would give me a hint. I want to create a

table inside another table and display data in that cell according to

different conditions. I feel I am close but I just couldn't get it. I doubt

the expression "if RS("Company_ID") = varID then" doesn't work at all. Would

you or anybody please help me with this piece of code? I have stared at it

and testing page for two days without any success. Is my logic wrong? why

the "if RS("Company_ID") = varID then" statement doesn't compare two numbers

even when they are the same?



Thank you very much for your help.

Ping



My codes:

=========

dim RS, output1, output2

varID = request.form("ID")



if not RS.eof then

   response.write	"<table>" & _

   "<tr>" &_

   "<th>Item </th>" &_

   "<th>Value </th>" &_

   "<th>Company</th>" &_

	do while not RS.eof

		output1 = "<tr><td>"

		output1 = output1 & RS("item")& "</td>"

 		output1 = output1 & "<td>" & RS("value") & "</td>"

		response.write output1



 'HERE IS TO CREATE AND POPULATE TABLE INSIDE A CELL(But blank results)

=====================================================================

 		response.write "<td>"

 				output2 = "<table><tr><td>"

                        if RS("Company_ID") = varID then

					output2 = output2 & RS("company") &

"</td></tr>"

					blnFound = true

				end if

				if RS("Division_ID") = varID then

					output2 = output2 & RS("division") &

"</td></tr>"

					blnFound = true

				end if

				response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "wrong number."

end if












Message #7 by Ping Li <pli@l...> on Thu, 20 Dec 2001 15:45:55 -0600
Scott, following is my code. Though I'm glad to see data appearing in a cell

within another table, I don't know why it company's name appear later than

division's name. Also, I need to have another if statement for invalid user

input.eg. if RS("company_ID")<>CLng(varID) or

RS("division_ID")<>CLng(varID), response.write "wrong ID" else...... I tried

to insert it in front of "if not RS.eof then" but didn't succeed. Would you

please take a look at my codes and see how I should proceed? Ping





dim RS, output1, output2

varID = request.form("ID")

set RS = server.createObject("ADODB,Recordset")

RS.Open * from Data



' for valid ID, create table.

=============================

if not RS.eof then

   response.write	"<table>" & _

   "<tr>" &_

   "<th>Item </th>" &_

   "<th>Value </th>" &_

   "<th>Company</th>" &_

	do while not RS.eof

		output1 = "<tr><td>"

		output1 = output1 & RS("item")& "</td>"

 		output1 = output1 & "<td>" & RS("value") & "</td>"

		response.write output1

   response.write "<td>"

 	output2 = "<table><tr><td>"

      if RS("Company_ID") = CLng(varID) then

		output2 = output2 & RS("company") & "</td></tr>"

		blnFound = true

		end if

	if blnFound or RS("Division_ID") = CLng(varID) then

		output2 = output2 & RS("division") & "</td></tr>"

		blnFound = true

		end if

   response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "You have no records."

end if









-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 4:24 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





blnFound has a boolean assignment so you really don't need that in your

second

conditional statement.



Not sure about the order of return, I would need to see more of your code. I

would,

however, suggest using a direct reference to the value...SQL("company).Value



Scott



-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 3:07 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





You were right, Scott, the user input data type isn't the same as that in my

database. When I use CLng(varID), data returned. But in the wrong order, the

division name comes first then company name. The intended order was company

name, then division's name. Can you think of a reason?



Thanks again for your help. Ping





response.write "<td>"

 	output2 = "<table><tr><td>"

      if RS("Company_ID") = varID then

		output2 = output2 & RS("company") & "</td></tr>"

		blnFound = true

		end if

'I missed blnFound part out of the second condition

===================================================

	if blnFound or RS("Division_ID") = varID then

		output2 = output2 & RS("division") & "</td></tr>"

		blnFound = true

		end if

response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "wrong number."

end if

-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 3:38 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





First, I suspect that the values are not what you think they are.

At the end of each loop, Response.Write each value to the page.

You will then be able to compare the values yourself.



Now, let's say that you assign the values manually (for testing's sake)



Dim varID

varID = "1234"

Dim Company_ID

Company_ID = "1234"



If Company_ID = varID Then

	Response.Write "BINGO"

Else

	Response.Write "FUBAR"

End If



If that case works but your other assignment of value does not,

make sure that the Variable "types" are the same and your not

comparing a String to an Integer(or whatever).In not entirely sure

but I think that field values collected from a form (user input)

are automatically stored as strings(?).



But again, the problem may be with the way this data is stored in

your database, they way you are retrieving the value or the way

your are storing the value. The first place to start is seeing what

is being returned for each item.



anyway, hope you figure it out...

Scott Reed





-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 2:06 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





Scott, thanks for your email. Company_ID and Division_ID are fields of my

recordset RS. varID is user input. What's bugging me is that when I input

1234 as ID and 1234 is truely the company A's ID in my database. So it's

supposed to return company's name. But no, nothing return. When I followed

your suggestion and added "else response.write "not a Company"", it returned

"not a company". That means the computer thinks 1234(Company_ID in database)

doesn't equal to 1234(user input). Do you know what I mean? they are the

same number, but the computer thinks not. I just don't understand.

Company_ID is set to be number, is the user input default to be number?



Ping



-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 2:59 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





according to your code....



If neither case is true (Company_ID or Division_ID is not equal to varID)

then nothing will get written to page. Your "else" statment is outside of

those nested loops.



You may want to toss in an "else" between each of the nested loops that

writes the value of Company_ID, Division_ID and varID to the page during

each itteration so that you can manually compare the values.



Nothing in your code assigns a value to Compay_ID or Division_ID so I can

only assume that is being done.



Message #8 by "Scott Reed" <scottr@m...> on Fri, 21 Dec 2001 09:57:09 -0600
Ping,



It looks as if you are collecting one field from a User Input form ("ID")

and comparing that to 2 separate return values from your database query

(Company_ID and Division_ID).



If these 2 fields are related, make a relationship in your database so that

you only need to compare one. Alternatively, you can use one "If Then" and

combine the two comparisons by using the "AND" keyword.



While Not RS.EOF AND RS.BOF 'you have at least one record



	If RS("Company_ID) = CLng(varID) AND RS("Division_ID) = CLng(varID) THEN

		Output stuff

	Else

		Response.Write "No Match Found"

	End If



Wend



I really don't see a need for you to iterate thought the RS but maybe I just

don't understand. You will want to handle other cases such as if more then

one record is returned or if only one of your comparisons produce a match.



You may also run into the problem....If you define the Max Length of your

input fields, your return will be the user input + Trailing spaces. So, if

you

have a field of 25 max length and someone types "88071" your return will get

a

string "88071                    " with 20 trailing spaces. Not only should

you convert

it to an Integer, you should trim those trailing spaces or it will cause

problems.



Scott

-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 3:46 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





Scott, following is my code. Though I'm glad to see data appearing in a cell

within another table, I don't know why it company's name appear later than

division's name. Also, I need to have another if statement for invalid user

input.eg. if RS("company_ID")<>CLng(varID) or

RS("division_ID")<>CLng(varID), response.write "wrong ID" else...... I tried

to insert it in front of "if not RS.eof then" but didn't succeed. Would you

please take a look at my codes and see how I should proceed? Ping





dim RS, output1, output2

varID = request.form("ID")

set RS = server.createObject("ADODB,Recordset")

RS.Open * from Data



' for valid ID, create table.

=============================

if not RS.eof then

   response.write	"<table>" & _

   "<tr>" &_

   "<th>Item </th>" &_

   "<th>Value </th>" &_

   "<th>Company</th>" &_

	do while not RS.eof

		output1 = "<tr><td>"

		output1 = output1 & RS("item")& "</td>"

 		output1 = output1 & "<td>" & RS("value") & "</td>"

		response.write output1

   response.write "<td>"

 	output2 = "<table><tr><td>"

      if RS("Company_ID") = CLng(varID) then

		output2 = output2 & RS("company") & "</td></tr>"

		blnFound = true

		end if

	if blnFound or RS("Division_ID") = CLng(varID) then

		output2 = output2 & RS("division") & "</td></tr>"

		blnFound = true

		end if

   response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "You have no records."

end if









-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 4:24 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





blnFound has a boolean assignment so you really don't need that in your

second

conditional statement.



Not sure about the order of return, I would need to see more of your code. I

would,

however, suggest using a direct reference to the value...SQL("company).Value



Scott



-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 3:07 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





You were right, Scott, the user input data type isn't the same as that in my

database. When I use CLng(varID), data returned. But in the wrong order, the

division name comes first then company name. The intended order was company

name, then division's name. Can you think of a reason?



Thanks again for your help. Ping





response.write "<td>"

 	output2 = "<table><tr><td>"

      if RS("Company_ID") = varID then

		output2 = output2 & RS("company") & "</td></tr>"

		blnFound = true

		end if

'I missed blnFound part out of the second condition

===================================================

	if blnFound or RS("Division_ID") = varID then

		output2 = output2 & RS("division") & "</td></tr>"

		blnFound = true

		end if

response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "wrong number."

end if

-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 3:38 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





First, I suspect that the values are not what you think they are.

At the end of each loop, Response.Write each value to the page.

You will then be able to compare the values yourself.



Now, let's say that you assign the values manually (for testing's sake)



Dim varID

varID = "1234"

Dim Company_ID

Company_ID = "1234"



If Company_ID = varID Then

	Response.Write "BINGO"

Else

	Response.Write "FUBAR"

End If



If that case works but your other assignment of value does not,

make sure that the Variable "types" are the same and your not

comparing a String to an Integer(or whatever).In not entirely sure

but I think that field values collected from a form (user input)

are automatically stored as strings(?).



But again, the problem may be with the way this data is stored in

your database, they way you are retrieving the value or the way

your are storing the value. The first place to start is seeing what

is being returned for each item.



anyway, hope you figure it out...

Scott Reed





-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 2:06 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





Scott, thanks for your email. Company_ID and Division_ID are fields of my

recordset RS. varID is user input. What's bugging me is that when I input

1234 as ID and 1234 is truely the company A's ID in my database. So it's

supposed to return company's name. But no, nothing return. When I followed

your suggestion and added "else response.write "not a Company"", it returned

"not a company". That means the computer thinks 1234(Company_ID in database)

doesn't equal to 1234(user input). Do you know what I mean? they are the

same number, but the computer thinks not. I just don't understand.

Company_ID is set to be number, is the user input default to be number?



Ping



-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 2:59 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





according to your code....



If neither case is true (Company_ID or Division_ID is not equal to varID)

then nothing will get written to page. Your "else" statment is outside of

those nested loops.



You may want to toss in an "else" between each of the nested loops that

writes the value of Company_ID, Division_ID and varID to the page during

each itteration so that you can manually compare the values.



Nothing in your code assigns a value to Compay_ID or Division_ID so I can

only assume that is being done.










Message #9 by Ping Li <pli@l...> on Fri, 21 Dec 2001 10:26:50 -0600
Thanks, Scott, I will try as you said. Merry Christmas to all.



-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Friday, December 21, 2001 9:57 AM

To: Access ASP

Subject: [access_asp] RE: table inside table





Ping,



It looks as if you are collecting one field from a User Input form ("ID")

and comparing that to 2 separate return values from your database query

(Company_ID and Division_ID).



If these 2 fields are related, make a relationship in your database so that

you only need to compare one. Alternatively, you can use one "If Then" and

combine the two comparisons by using the "AND" keyword.



While Not RS.EOF AND RS.BOF 'you have at least one record



	If RS("Company_ID) = CLng(varID) AND RS("Division_ID) = CLng(varID)

THEN

		Output stuff

	Else

		Response.Write "No Match Found"

	End If



Wend



I really don't see a need for you to iterate thought the RS but maybe I just

don't understand. You will want to handle other cases such as if more then

one record is returned or if only one of your comparisons produce a match.



You may also run into the problem....If you define the Max Length of your

input fields, your return will be the user input + Trailing spaces. So, if

you

have a field of 25 max length and someone types "88071" your return will get

a

string "88071                    " with 20 trailing spaces. Not only should

you convert

it to an Integer, you should trim those trailing spaces or it will cause

problems.



Scott

-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 3:46 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





Scott, following is my code. Though I'm glad to see data appearing in a cell

within another table, I don't know why it company's name appear later than

division's name. Also, I need to have another if statement for invalid user

input.eg. if RS("company_ID")<>CLng(varID) or

RS("division_ID")<>CLng(varID), response.write "wrong ID" else...... I tried

to insert it in front of "if not RS.eof then" but didn't succeed. Would you

please take a look at my codes and see how I should proceed? Ping





dim RS, output1, output2

varID = request.form("ID")

set RS = server.createObject("ADODB,Recordset")

RS.Open * from Data



' for valid ID, create table.

=============================

if not RS.eof then

   response.write	"<table>" & _

   "<tr>" &_

   "<th>Item </th>" &_

   "<th>Value </th>" &_

   "<th>Company</th>" &_

	do while not RS.eof

		output1 = "<tr><td>"

		output1 = output1 & RS("item")& "</td>"

 		output1 = output1 & "<td>" & RS("value") & "</td>"

		response.write output1

   response.write "<td>"

 	output2 = "<table><tr><td>"

      if RS("Company_ID") = CLng(varID) then

		output2 = output2 & RS("company") & "</td></tr>"

		blnFound = true

		end if

	if blnFound or RS("Division_ID") = CLng(varID) then

		output2 = output2 & RS("division") & "</td></tr>"

		blnFound = true

		end if

   response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "You have no records."

end if









-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 4:24 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





blnFound has a boolean assignment so you really don't need that in your

second

conditional statement.



Not sure about the order of return, I would need to see more of your code. I

would,

however, suggest using a direct reference to the value...SQL("company).Value



Scott



-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 3:07 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





You were right, Scott, the user input data type isn't the same as that in my

database. When I use CLng(varID), data returned. But in the wrong order, the

division name comes first then company name. The intended order was company

name, then division's name. Can you think of a reason?



Thanks again for your help. Ping





response.write "<td>"

 	output2 = "<table><tr><td>"

      if RS("Company_ID") = varID then

		output2 = output2 & RS("company") & "</td></tr>"

		blnFound = true

		end if

'I missed blnFound part out of the second condition

===================================================

	if blnFound or RS("Division_ID") = varID then

		output2 = output2 & RS("division") & "</td></tr>"

		blnFound = true

		end if

response.write output2 & "</table>" &_

			"</td>" &_

			"</tr>"

		rscases.MoveNext

	Loop

	response.write "</table>"

else

	response.write "wrong number."

end if

-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 3:38 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





First, I suspect that the values are not what you think they are.

At the end of each loop, Response.Write each value to the page.

You will then be able to compare the values yourself.



Now, let's say that you assign the values manually (for testing's sake)



Dim varID

varID = "1234"

Dim Company_ID

Company_ID = "1234"



If Company_ID = varID Then

	Response.Write "BINGO"

Else

	Response.Write "FUBAR"

End If



If that case works but your other assignment of value does not,

make sure that the Variable "types" are the same and your not

comparing a String to an Integer(or whatever).In not entirely sure

but I think that field values collected from a form (user input)

are automatically stored as strings(?).



But again, the problem may be with the way this data is stored in

your database, they way you are retrieving the value or the way

your are storing the value. The first place to start is seeing what

is being returned for each item.



anyway, hope you figure it out...

Scott Reed





-----Original Message-----

From: Ping Li [mailto:pli@l...]

Sent: Thursday, December 20, 2001 2:06 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





Scott, thanks for your email. Company_ID and Division_ID are fields of my

recordset RS. varID is user input. What's bugging me is that when I input

1234 as ID and 1234 is truely the company A's ID in my database. So it's

supposed to return company's name. But no, nothing return. When I followed

your suggestion and added "else response.write "not a Company"", it returned

"not a company". That means the computer thinks 1234(Company_ID in database)

doesn't equal to 1234(user input). Do you know what I mean? they are the

same number, but the computer thinks not. I just don't understand.

Company_ID is set to be number, is the user input default to be number?



Ping



-----Original Message-----

From: Scott Reed [mailto:scottr@m...]

Sent: Thursday, December 20, 2001 2:59 PM

To: Access ASP

Subject: [access_asp] RE: table inside table





according to your code....



If neither case is true (Company_ID or Division_ID is not equal to varID)

then nothing will get written to page. Your "else" statment is outside of

those nested loops.



You may want to toss in an "else" between each of the nested loops that

writes the value of Company_ID, Division_ID and varID to the page during

each itteration so that you can manually compare the values.



Nothing in your code assigns a value to Compay_ID or Division_ID so I can

only assume that is being done.
















  Return to Index