# Select Case problem



## coachdan32 (Nov 13, 2003)

I am having problems with a case select statement. I am getting a "Provider error '80020005' Type Mismatch" error on line 401. This line is the "Case 2002" line that follows the "Else" line. There is a dropdown called varBusName that allows 2 selections "Citi" or "Sears". The first set of case selections are designated to a "Citi" choice and the second set (after the "Else") is designated to the "Sears" choice. varYrA is another dropdown on the page that allows them to choose a year. There is a db setup for each of the choices. Can anyone see what might be the problem? I have never seen a type mismatch error on anything but a conversion of a data type. I have this select on another page and it works OK.

If varBusName = "Citi" Then
Select Case varYrA
Case "2002"
varDB = "Training_Delivery_Data.mdb"
Case "2003"
varDB = "Training_Delivery_Data03.mdb"
Case "2004"
varDB = "Training_Delivery_Data04.mdb"
Case "2005"
varDB="Training_Delivery_Data05.mdb"
Case "2006"
varDB="Training_Delivery_Data06.mdb"
Case "2007"
varDB="Training_Delivery_Data07.mdb"
Case "2008"
varDB="Training_Delivery_Data08.mdb"
Case "2009"
varDB="Training_Delivery_Data09.mdb"
Case "2010"
varDB="Training_Delivery_Data10.mdb"
End Select
Else
Select Case varYrA
Case "2002"
varDB = "Training_Delivery_DataSears.mdb"
Case "2003"
varDB = "Training_Delivery_Data03Sears.mdb"
Case "2004"
varDB = "Training_Delivery_Data04Sears.mdb"
Case "2005"
varDB = "Training_Delivery_Data05Sears.mdb"
Case "2006"
varDB = "Training_Delivery_Data06Sears.mdb"
Case "2007"
varDB = "Training_Delivery_Data07Sears.mdb"
Case "2008"
varDB = "Training_Delivery_Data08Sears.mdb"
Case "2009"
varDB = "Training_Delivery_Data09Sears.mdb"
Case "2010"
varDB = "Training_Delivery_Data10Sears.mdb"
End Select
End If


----------



## Rockn (Jul 29, 2001)

Use ELSE IF varBusName = "Sears" Then do your select case.

Why do you have 18 different databases in your application??


----------



## Gibble (Oct 10, 2001)

Just a suggestion, you might try changing your code to something more...fluid.

ie.

```
dim lsYear as String
lsYear = Right(varYrA, 2)

if varBusName = "Citi" Then
	varDB = "Training_Delivery_Data" & lsYear & ".mdb"
else
	varDB = "Training_Delivery_Data" & lsYear & "Sears.mdb"
end if
```


----------



## coachdan32 (Nov 13, 2003)

I tried that and still get the same error message, only the line returned goes to 402 instead of 401. I will attach the whole file, I am starting to think that the line being returned is misleading and the problem lies elsewhere.

In answer to your db question, this was done as a fast solution to split the application to 2 businesses. The better way would have been to use one db, but that would have required many changes within the db and affected all of the over 150 pages within the site. Obviously that would have taken a long period of time to accomplish and I only had a 2 week window to make it happen. It will only remain that way until the first of the year and then each business will maintain their own.


----------



## coachdan32 (Nov 13, 2003)

I'm new to this forum, why is my attached file not showing up? I did attach it before submitting my reply.


----------



## Rockn (Jul 29, 2001)

Did you try and attach a file or insert code?


----------



## coachdan32 (Nov 13, 2003)

I tried to attach an asp file.


----------



## coachdan32 (Nov 13, 2003)

I will try attaching a text file. Next time I should read the small print.


----------



## Gibble (Oct 10, 2001)

WOW...You can reduce that code into ALOT less...

let me reduce that and paste back what I come up with...


----------



## Gibble (Oct 10, 2001)

btw, what the heck is this doing?


```
For C = 1 to UU
	CurRecs = (Request.Form("UCodes").Count)
	REDIM PRESERVE UCodes(CurRecs)
Next
```
It doesn't serve any purpose that I can see in the code...


----------



## coachdan32 (Nov 13, 2003)

Gibble,

I wish I could answer that myself. This is a page I inherited when I took over my position. I have been able to figure most of the coding in the pages out, but I have no clue what the programmer was accomplishing with it. I am pretty new to programming and do a lot of feeling my way through existing code.


----------



## Gibble (Oct 10, 2001)

Ok, save the current file as something else, and try to replace it with this, I cleaned up the code, and this should work exactly the same as what you had, but until it's tested I won't make any guarantees.


```
<%@language="vbscript"%>
<%
varBusName = Session("varRedirectBus")
%>
<!--#include file="global.asa"-->
<!--#include file="include/Connect.asp"-->
<html>
<head>
	<title>Trainer Attendance and Utilization Confirmation Page</title>
</head>

<body background="WB00760_.gif">
	<hr>
	<hr>
	<p><font size="5">Trainer Attendance and Utilization Confirmation Page</font></p>
	<hr>
	<hr>
	<!--#include file="include/menu.asp"-->
	<%

	TName = Request.Form("TName")
	UUCodes() = Request.Form("UCodes").Count

	If (TName=" ") Then
		Response.Write "<H2>ERRORS PLEASE CORRECT</H2>"
		Response.Write "Please Enter: <H2>'TRAINER NAME'</H2> <BR><BR>"
		Response.Write "Use your Back Button to correct field - Use reset to clear all fields."
		Response.End
	End If

	if UUCodes() = 35 then UCount = 28 else UCount = 35
	For i = 1 to UCount
		If(Request.Form("UCodes")(i) = " " ) Then
			Response.Write "<H2>ERRORS PLEASE CORRECT</H2>"
			Response.Write "Please Enter: <H2>'Week 1 Day 1 Data'</H2> <BR><BR>"
			Response.Write "Use your Back Button to correct field - Use reset to clear all fields."
			Response.End
		End If
	Next

	SQLFT = " SELECT Trainers.TId, Trainers.LocCity, Trainers.TName "
	SQLFT = SQLFT & " FROM Trainers "
	SQLFT = SQLFT & " WHERE Trainers.TName LIKE '%" & TName & "%'"' "

	Set rsFT = Conn.Execute(SQLFT)

		varTId = CInt(rsFT("TId").Value)
		varLocCity = rsFT("LocCity").Value

	rsFT.Close
	Set rsFT=Nothing

	'Pull data from DBase table for building tables on Form

	varMonth = Request.Form("MonMonth")
	varYear = Request.Form("YrYear")


	Dim UCodes()
	Dim C

	For C = 1 to UU
		UCodes(C) = Request.Form("UCodes")(C)
	Next


	'*************************** LOAD TABLE ********************
	'
	dim lsYear as String
	lsYear = Right(varYrA, 2)

	if varBusName = "Citi" Then
		varDB = "Training_Delivery_Data" & lsYear & ".mdb"
	else
		varDB = "Training_Delivery_Data" & lsYear & "Sears.mdb"
	end if

	Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(varDB) & ";"
	SQLAdd = " SELECT * FROM TrainersAUCodes() "
	Set uRS = Server.CreateObject("ADODB.Recordset")
	uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic


	uRS.AddNew

	uRS.Fields("TName") = TName
	uRS.Fields("LocCity") = varLocCity
	uRS.Fields("TId") = varTId
	uRS.Fields("Month") = varMonth
	uRS.Fields("Year") = varYear

	For i = 1 to 35
		uRS.Fields("U" & i) = UCodes(i)
	Next

	uRS.Update

	uRS.Close
	Set uRS=nothing
	%>

	<h2>TAUCodes() Confirm Page</h2>

	<%
	Response.Write "Here are the Records that have been entered"

	Response.Write ("<table border=1>")

	Response.Write ("<tr><th>Trainer Name</th><th>Month</th><th>Year</th></tr>")
	Response.Write ("<tr><td>" & TName & "</td><td>" & varMonth & "</td><td>" & varYear & "</td><td>" & varVBUCodes() & "</td></tr>")


	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")
	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")

	Response.Write ("<tr>")
	for i = 1 to 7
		Response.Write ("<th>&nbsp;Code Day " & i  & "</th>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr>")
	for i = 1 to 7
		Response.Write ("<td>" & UCodes(i) & "</td>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")
	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")

	Response.Write ("<tr>")
	for i = 8 to 14
		Response.Write ("<th>&nbsp;Code Day " & i  & "</th>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr>")
	for i = 8 to 14
		Response.Write ("<td>" & UCodes(i) & "</td>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")
	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")

	Response.Write ("<tr>")
	for i = 15 to 28
		Response.Write ("<th>&nbsp;Code Day " & i  & "</th>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr>")
	for i = 15 to 28
		Response.Write ("<td>" & UCodes(i) & "</td>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")
	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")

	Response.Write ("<tr>")
	for i = 29 to 35
		Response.Write ("<th>&nbsp;Code Day " & i  & "</th>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr>")
	for i = 29 to 35
		Response.Write ("<td>" & UCodes(i) & "</td>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")
	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")

	Response.Write ("</table>")
	%>

	<p>
	<a HREF="TAUCALRD.asp?Yr=<%=varYrA%>">Click Here to Enter Additional 'TAU' Data</a>
	<br>
	<br>
	<a HREF="/../Default.asp">Click Here for Main Menu</a>
	</p>
</body>
</html>

<%
Conn.Close
Set Conn=Nothing
%>
```


----------



## coachdan32 (Nov 13, 2003)

I get the exact same error message as before. The code is definately more concise and efficient though. I appreciate the effort and if we can solve the mystery I will definately adopt the concept.


----------



## Gibble (Oct 10, 2001)

where in my code is the err?


----------



## Gibble (Oct 10, 2001)

Try changing this:

```
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(varDB) & ";"
SQLAdd = " SELECT * FROM TrainersAUCodes() "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
```
To this:


```
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(varDB) & ";"
SQLAdd = " SELECT * FROM TrainersAUCodes() "
Set uCN = Server.CreateObject("ADODB.Connection")
Set uRS = Server.CreateObject("ADODB.Recordset")

On Error Resume Next
uCN.Open Connect
if ERR.Number <> 0 then
	Response.Write("Error Number -> " & Err.Number)
    Response.write("<BR>Error Source -> " & Err.Source)
    Response.Write("<BR>Error Desc   -> " & Err.Description)
    Response.Write("<BR>Connect -> " & Connect)
    Err.Clear
end if

uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
```
And let me know if it gives an error? If so it means your Connection string "Provider=Mi..." is no good.


----------



## coachdan32 (Nov 13, 2003)

It returns the following error:

Microsoft VBScript compilation error '800a0401' 

Expected end of statement 

/Training_Dept/TAUCALCP.asp, line 75 

dim lsYear as String
-----------^


----------



## Gibble (Oct 10, 2001)

Oh, whoops.

Just take out that line.
I forgot you were using ASP so you don't define variables


----------



## coachdan32 (Nov 13, 2003)

Still returning the following:

Microsoft VBScript compilation error '800a03f6' 

Expected 'End' 

/Training_Dept/TAUCALCP.asp, line 196


----------



## Gibble (Oct 10, 2001)

Here I just made all the changes to the file...


```
<%@language="vbscript"%>
<%
varBusName = Session("varRedirectBus")
%>
<!--#include file="global.asa"-->
<!--#include file="include/Connect.asp"-->
<html>
<head>
	<title>Trainer Attendance and Utilization Confirmation Page</title>
</head>

<body background="WB00760_.gif">
	<hr>
	<hr>
	<p><font size="5">Trainer Attendance and Utilization Confirmation Page</font></p>
	<hr>
	<hr>
	<!--#include file="include/menu.asp"-->
	<%

	TName = Request.Form("TName")
	UU = Request.Form("UCodes").Count

	If (TName=" ") Then
		Response.Write "<H2>ERRORS PLEASE CORRECT</H2>"
		Response.Write "Please Enter: <H2>'TRAINER NAME'</H2> <BR><BR>"
		Response.Write "Use your Back Button to correct field - Use reset to clear all fields."
		Response.End
	End If

	if UU = 35 then UCount = 28 else UCount = 35
	For i = 1 to UCount
		If(Request.Form("UCodes")(i) = " " ) Then
			Response.Write "<H2>ERRORS PLEASE CORRECT</H2>"
			Response.Write "Please Enter: <H2>'Week 1 Day 1 Data'</H2> <BR><BR>"
			Response.Write "Use your Back Button to correct field - Use reset to clear all fields."
			Response.End
		End If
	Next

	SQLFT = " SELECT Trainers.TId, Trainers.LocCity, Trainers.TName "
	SQLFT = SQLFT & " FROM Trainers "
	SQLFT = SQLFT & " WHERE Trainers.TName LIKE '%" & TName & "%'"' "

	Set rsFT = Conn.Execute(SQLFT)

		varTId = CInt(rsFT("TId").Value)
		varLocCity = rsFT("LocCity").Value

	rsFT.Close
	Set rsFT=Nothing

	'Pull data from DBase table for building tables on Form

	varMonth = Request.Form("MonMonth")
	varYear = Request.Form("YrYear")


	Dim UCodes()
	Dim C

	For C = 1 to UCount
		UCodes(C) = Request.Form("UCodes")(C)
	Next


	'*************************** LOAD TABLE ********************
	'
	dim lsYear
	lsYear = Right(varYrA, 2)

	if varBusName = "Citi" Then
		varDB = "Training_Delivery_Data" & lsYear & ".mdb"
	else
		varDB = "Training_Delivery_Data" & lsYear & "Sears.mdb"
	end if

	Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(varDB) & ";"
	SQLAdd = " SELECT * FROM TrainersAUCodes() "
	Set uRS = Server.CreateObject("ADODB.Recordset")
	uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic


	uRS.AddNew

	uRS.Fields("TName") = TName
	uRS.Fields("LocCity") = varLocCity
	uRS.Fields("TId") = varTId
	uRS.Fields("Month") = varMonth
	uRS.Fields("Year") = varYear

	For i = 1 to 35
		uRS.Fields("U" & i) = UCodes(i)
	Next

	uRS.Update

	uRS.Close
	Set uRS=nothing
	%>

	<h2>TAUCodes() Confirm Page</h2>

	<%
	Response.Write "Here are the Records that have been entered"

	Response.Write ("<table border=1>")

	Response.Write ("<tr><th>Trainer Name</th><th>Month</th><th>Year</th></tr>")
	Response.Write ("<tr><td>" & TName & "</td><td>" & varMonth & "</td><td>" & varYear & "</td><td>" & varVBUCodes() & "</td></tr>")


	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")
	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")

	Response.Write ("<tr>")
	for i = 1 to 7
		Response.Write ("<th> Code Day " & i  & "</th>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr>")
	for i = 1 to 7
		Response.Write ("<td>" & UCodes(i) & "</td>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")
	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")

	Response.Write ("<tr>")
	for i = 8 to 14
		Response.Write ("<th> Code Day " & i  & "</th>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr>")
	for i = 8 to 14
		Response.Write ("<td>" & UCodes(i) & "</td>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")
	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")

	Response.Write ("<tr>")
	for i = 15 to 28
		Response.Write ("<th> Code Day " & i  & "</th>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr>")
	for i = 15 to 28
		Response.Write ("<td>" & UCodes(i) & "</td>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")
	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")

	Response.Write ("<tr>")
	for i = 29 to 35
		Response.Write ("<th> Code Day " & i  & "</th>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr>")
	for i = 29 to 35
		Response.Write ("<td>" & UCodes(i) & "</td>")
	next 
	Response.Write ("</tr>")

	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")
	Response.Write ("<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>")

	Response.Write ("</table>")
	%>

	<p>
	<a HREF="TAUCALRD.asp?Yr=<%=varYrA%>">Click Here to Enter Additional 'TAU' Data</a>
	<br>
	<br>
	<a HREF="/../Default.asp">Click Here for Main Menu</a>
	</p>
</body>
</html>

<%
Conn.Close
Set Conn=Nothing
%>
```


----------



## coachdan32 (Nov 13, 2003)

Microsoft VBScript runtime error '800a0009' 

Subscript out of range 

/Training_Dept/TAUCALCP.asp, line 71


Also, based on what you advised earlier, should I remove:


Dim UCodes() 
Dim C


----------



## coachdan32 (Nov 13, 2003)

Since the error returns on the line of the dim statement, I went ahead and tried that and got the following:

Microsoft VBScript runtime error '800a000d' 

Type mismatch: 'UCodes' 

/Training_Dept/TAUCALCP.asp, line 69


----------



## Gibble (Oct 10, 2001)

Change 
Dim UCodes() 
to
Dim UCodes(35)


----------



## coachdan32 (Nov 13, 2003)

Gibble,

It went through with no error messages, but when checking the db for the record - I find no record listed. I chose "Citi" and year "2003" from the dropdowns and the db that is designated for Citi 2003 has no record. I also checked the Sears 2003 db and it doesn't either. I am going to do some looking around and try to find out where it got posted to.


----------



## Gibble (Oct 10, 2001)

The easiest way to debug in asp is using

Response.write and Response.end 

Right after this line 
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath(varDB) & ";"

Put:
Response.write Connect
Response.end

It will pring out the Connect string and stop, check and make sure the path to the database file is correct


----------



## coachdan32 (Nov 13, 2003)

Gibble,

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\space\training.atc.sears.com\Training_Dept\Training_Delivery_Data03.mdb;

It looks right to me. I'm not sure what the "\space\" portion of the path is referring to but, the site is training.atc.sears.com - which, on my computer, can be found on my "D:" drive. The db is found in a directory named Training_Dept and it is named Training_Delivery_Data03.mdb. But, there is definately no record that matches what I entered in the TAU table. In fact, I checked all the db's and it does not exist.


----------



## Gibble (Oct 10, 2001)

Well if the file isn't saved at 
D:\space\training.atc.sears.com\Training_Dept\Training_Delivery_Data03.mdb;
then it won't be found. Find out exactly where the file is. And I'll alter the code to work


----------



## coachdan32 (Nov 13, 2003)

From my computer, my path is D:\Training_Dept\Training_Delivery_Data03.mdb

but, D: is a mapped drive to an off-site server that is the webserver. The website name is training.atc.sears.com - I am not sure what is needed. In other apps, we have used server.mappath(dbName) and it worked fine. I would guess that the path would need to be:

\training.atc.sears.com\Training_Dept\Training_Delivery_Data03.mdb

that would represent server\directory\filename. I'm not sure whether the drive letter is necessary (being that it is a mapped drive off-site) or not. 

I appreciate your patience while I am a newby.


----------



## Gibble (Oct 10, 2001)

What server.mappath does is prepend the servers physical path.

Which appears to be:
D:\space\training.atc.sears.com\Training_Dept\

Now, are these database files stored on the off-site webserver? I am assuming they are.

If that's the case, you need to find out exactly where on that server they are, what the complete directory is.

They may be on your computer at d:\Training_Dept\Training_Delivery_Data03.mdb, but the code is (and was before I mucked with it) trying to load the database stored on the webserver.

If the databases are stored on the webserver, where the code things they are, they should be at.

http://training.atc.sears.com/Training_Dept/Training_Delivery_Data03.mdb

See if you can get a file from that location. I can't because I can't get at that server. But you probably can. If there is no file there, the code is looking in the wrong place and you need to find out exactly where the database files are saved on the server.

Hope I didn't confuse you too much.
--Gibbs


----------



## Gibble (Oct 10, 2001)

Any luck so far?


----------



## coachdan32 (Nov 13, 2003)

Gibble,

Sorry it took so long for me to respond, I was off work until Monday. The db files are located on the webserver. The path that was originally used should be the correct path, because the connection string that is on it was being used (and worked) before I had to alter it for the new business.


----------



## coachdan32 (Nov 13, 2003)

Gibble,

The problem is not in the db path. I don't know why I didn't think of it before but, I finally came up with the thought to do the Response.write for the path on the original file that worked before the changes - and the path that came back was identical to the one created by your code. So the problem lies elsewhere.


----------



## coachdan32 (Nov 13, 2003)

Gibble,

I found the problem. In the SQL statement, it said to:

Select * from TrainersAUCodes() ;

and it should have been:

Select * from TrainersAU ;

Now it posts to the db. However, I am still having one strange issue. It is not posting the varMonth and varYrA, but rather is leaving the fields blank. Do you have any suggestions on why that could be?


----------



## coachdan32 (Nov 13, 2003)

I tested the two variables (varMonth, varYear) with a Response.write and it returns no values for either. To give you some background info:

varYear - comes from varYrA, which is a dropdown on the initial start page.

varMonth - comes from a dropdown on a page (TAUCALRD.asp) that gathers the month and then dynamically builds the table based on what month is picked from varMonth.

There have been no changes to either of these pages.


----------



## Gibble (Oct 10, 2001)

Those two vars are set on these lines:

```
varMonth = Request.Form("MonMonth")
varYear = Request.Form("YrYear")
```
Assuming the form that triggers this page sends MonMonth and YrYear to this script, the values should be there.


----------



## coachdan32 (Nov 13, 2003)

It is being passed as a hidden field. I am really baffled on why it is not posting. Do you have any insight on other things that could cause it?

" METHOD="POST">
">">


----------



## Gibble (Oct 10, 2001)

Have you made sure that the hidden field has the value when that page is loaded?


----------



## Rockn (Jul 29, 2001)

Do your response.write test once again to see if it will print those variables to the screen. If it doesn't try plugging a set value in for the variable and see if it works. The variables for year and date are probably set up wrong or ar not passing to the form.


----------



## coachdan32 (Nov 13, 2003)

When I tested the variables they were empty. I have tried carrying the variable value with a session variable and that didn't work for me either. These values were being passed successfully prior to the changes and I don't see anything that was changed that should affect them. The way this was setup is kind of hard to follow. There is a main page that collects the year and business name. The year selected from that page tells it what MenuDefault page to use. There is a MenuDefault page for each year. The MenuDefault page is like a directory of pages for the user to choose from. I was able to successfully pass the year variable to the MenuDefault page with a session variable (I checked with a response.write), but when I call the session variable on this page and ask it to post the value to the db - nothing is passed. I don't get an error, just nothing is passed. Below is how I called the session variable and converted it to a year.

<%
varBusName = Session("varRedirectBus")
varYr = Session("varYear")

If NOT IsEmpty(Session("varYear")) Then
Select Case varYear
Case "MenuDefault.asp"
varYr = "2002"
Case "MenuDefault03.asp"
varYr = "2003"
Case "MenuDefault04.asp"
varYr = "2004"
Case "MenuDefault05.asp"
varYr="2005"
Case "MenuDefault06.asp"
varYr="2006"
Case "MenuDefault07.asp"
varYr="2007"
Case "MenuDefault08.asp"
varYr="2008"
Case "MenuDefault09.asp"
varYr="2009"
Case "MenuDefault10.asp"
varYr="2010"
End Select
Else

End If
%>

And then I asked for the variable to be posted to the db like this:

uRS.Fields("Year") = varYr

Does anyone see what I am doing wrong? Or why the changes we made to the original page affected the passing of these variables?


----------



## coachdan32 (Nov 13, 2003)

I did a response.write on the page that the following values are pulled from and it return the correct values for them.

varMonth = Request.Form("MonMonth") 
varYear = Request.Form("YrYear")

They are passed to this page using hidden values and for some reason the values are not getting to this page.


----------



## coachdan32 (Nov 13, 2003)

After much deliberation, I finally tracked the month problem down to a page that wasn't passing it properly and fixed it. The year problem was a nightmare because of the way the site is laid out. I got around it by using a session variable to pass the year value. Not an ideal situation, but should work. Many thanks to Gibble and Rockn for their patience and assistance.


----------



## Gibble (Oct 10, 2001)

So everything works now?


----------



## coachdan32 (Nov 13, 2003)

It seems to be working fine after just preliminary testing. Time will tell once it hits the Production server for the true tests. Thanks for the help.

I have another page that was built almost exactly like that one that I am trying to fix and make more efficient. I am trying to reuse a lot of your logic and code, but there are a couple areas that I have not been able to shorten. I will post them below and if you would be willing to look at them, I would be grateful. I can see that there is a pattern that is repeated throughout the codes, but have been unable to figure out how to remove the redundency.

'Need to make this more efficient


KCO = Request.Form("KCOCodes").Count



Dim KCOCodes(35)
Dim C

For C = 1 to KCO
CurRecs = (Request.Form("KCOCodes").Count)
REDIM PRESERVE KCOCodes(CurRecs)
Next





KCO1 = Request.Form("KCOCodes")(1)
KCO2 = Request.Form("KCOCodes")(2)
KCO3 = Request.Form("KCOCodes")(3)
KCO4 = Request.Form("KCOCodes")(4)
KCO5 = Request.Form("KCOCodes")(5)
KCO6 = Request.Form("KCOCodes")(6)
KCO7 = Request.Form("KCOCodes")(7)
KCO8 = Request.Form("KCOCodes")(8)
KCO9 = Request.Form("KCOCodes")(9)
KCO10 = Request.Form("KCOCodes")(10)
KCO11 = Request.Form("KCOCodes")(11)
KCO12 = Request.Form("KCOCodes")(12)
KCO13 = Request.Form("KCOCodes")(13)
KCO14 = Request.Form("KCOCodes")(14)
KCO15 = Request.Form("KCOCodes")(15)
KCO16 = Request.Form("KCOCodes")(16)
KCO17 = Request.Form("KCOCodes")(17)
KCO18 = Request.Form("KCOCodes")(18)
KCO19 = Request.Form("KCOCodes")(19)
KCO20 = Request.Form("KCOCodes")(20)
KCO21 = Request.Form("KCOCodes")(21)
KCO22 = Request.Form("KCOCodes")(22)
KCO23 = Request.Form("KCOCodes")(23)
KCO24 = Request.Form("KCOCodes")(24)
KCO25 = Request.Form("KCOCodes")(25)
KCO26 = Request.Form("KCOCodes")(26)
KCO27 = Request.Form("KCOCodes")(27)
KCO28 = Request.Form("KCOCodes")(28)

if Request.Form("KCOCodes").Count = 35 Then


KCO29 = Request.Form("KCOCodes")(29)
KCO30 = Request.Form("KCOCodes")(30)
KCO31 = Request.Form("KCOCodes")(31)
KCO32 = Request.Form("KCOCodes")(32)
KCO33 = Request.Form("KCOCodes")(33)
KCO34 = Request.Form("KCOCodes")(34)
KCO35 = Request.Form("KCOCodes")(35)


end if


And this:

If (KCO1 =" ") Then
KCO1 = Null
else
KCO1 = CSng(KCO1)
end if
If (KCO2 =" ") Then
KCO2 = Null
else
KCO2 = CSng(KCO2)
end if
If (KCO3 =" ") Then
KCO3 = Null
else
KCO3 = CSng(KCO3)
end if
If (KCO4 =" ") Then
KCO4 = Null
else
KCO4 = CSng(KCO4)
end if
If (KCO5 =" ") Then
KCO5 = Null
else
KCO5 = CSng(KCO5)
end if
If (KCO6 =" ") Then
KCO6 = Null
else
KCO6 = CSng(KCO6)
end if
If (KCO7 =" ") Then
KCO7 = Null
else
KCO7 = CSng(KCO7)
end if
If (KCO8 =" ") Then
KCO8 = Null
else
KCO8 = CSng(KCO8)
end if
If (KCO9 =" ") Then
KCO9 = Null
else
KCO9 = CSng(KCO9)
end if
If (KCO10 =" ") Then
KCO10 = Null
else
KCO10 = CSng(KCO10)
end if
If (KCO11 =" ") Then
KCO11 = Null
else
KCO11 = CSng(KCO11)
end if
If (KCO12 =" ") Then
KCO12 = Null
else
KCO12 = CSng(KCO12)
end if
If (KCO13 =" ") Then
KCO13 = Null
else
KCO13 = CSng(KCO13)
end if
If (KCO14 =" ") Then
KCO14 = Null
else
KCO14 = CSng(KCO14)
end if
If (KCO15 =" ") Then
KCO15 = Null
else
KCO15 = CSng(KCO15)
end if
If (KCO16 =" ") Then
KCO16 = Null
else
KCO16 = CSng(KCO16)
end if
If (KCO17 =" ") Then
KCO17 = Null
else
KCO17 = CSng(KCO17)
end if
If (KCO18 =" ") Then
KCO18 = Null
else
KCO18 = CSng(KCO18)
end if
If (KCO19 =" ") Then
KCO19 = Null
else
KCO19 = CSng(KCO19)
end if
If (KCO20 =" ") Then
KCO20 = Null
else
KCO20 = CSng(KCO20)
end if
If (KCO21 =" ") Then
KCO21 = Null
else
KCO21 = CSng(KCO21)
end if
If (KCO22 =" ") Then
KCO22 = Null
else
KCO22 = CSng(KCO22)
end if
If (KCO23 =" ") Then
KCO23 = Null
else
KCO23 = CSng(KCO23)
end if
If (KCO24 =" ") Then
KCO24 = Null
else
KCO24 = CSng(KCO24)
end if
If (KCO25 =" ") Then
KCO25 = Null
else
KCO25 = CSng(KCO25)
end if
If (KCO26 =" ") Then
KCO26 = Null
else
KCO26 = CSng(KCO26)
end if
If (KCO27 =" ") Then
KCO27 = Null
else
KCO27 = CSng(KCO27)
end if
If (KCO28 =" ") Then
KCO28 = Null
else
KCO28 = CSng(KCO28)
end if
If (KCO29 =" ") Then
KCO29 = Null
else
KCO29 = CSng(KCO29)
end if
If (KCO30 =" ") Then
KCO30 = Null
else
KCO30 = CSng(KCO30)
end if
If (KCO31 =" ") Then
KCO31 = Null
else
KCO31 = CSng(KCO31)
end if
If (KCO32 =" ") Then
KCO32 = Null
else
KCO32 = CSng(KCO32)
end if
If (KCO33 =" ") Then
KCO33 = Null
else
KCO33 = CSng(KCO33)
end if
If (KCO34 =" ") Then
KCO34 = Null
else
KCO34 = CSng(KCO34)
end if
If (KCO35 =" ") Then
KCO35 = Null
else
KCO35 = CSng(KCO35)
end if


----------



## coachdan32 (Nov 13, 2003)

Gibble,

I may have figured it out on my own, but it seems like it was simpler than I was making it - so maybe what I have is wrong. Here are my attempts, please advise me if I am wrong.

On the first:

For i = 1 to 35
KCO(i) = Request.Form("KCOCodes")(i)
Next

On the second:

For i = 1 to 35
If (KCO(i) = " ") Then
KCO(i) = Null
Else
KCO(i) = CSng(KCO(i))
End If
Next


----------



## Gibble (Oct 10, 2001)

The only thing I'd change is:
For i = 1 to 35
Make it
For i = 1 to Request.Form("KCOCodes").Count
and in the second
For i = 1 to KCO.Count

That should work, then it doesn't neccesarily have to be 35 to keep working


----------



## coachdan32 (Nov 13, 2003)

Really!! I was that close. I guess your starting to rub off on me. Thanks for the advice.


----------

