I had a logic error in a portion of code that I am trying to straighten out. I have rewritten the code but I am getting an Expected Statement error. The logic needs to be that if "Citi" is selected from the varBusName dropdown, it needs to look at the year selected in the varYrA dropdown and choose the correct db to transfer the data to. If "Sears" is selected, then it should look to the varYrA for a year and choose from a different set of db's. Am I missing an "end if" or something?
coachdan32
Code:
If varBusName = "Citi" Then
If varYrA = "2002" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2003" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data03.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2004" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data04.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2005" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data05.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2006" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data06.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2007" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data07.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2008" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data08.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2009" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data09.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2010" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data10.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
If varBusName = "Sears" Then
If varYrA = "2002" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_DataSears.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2003" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data03Sears.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2004" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data04Sears.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2005" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data05Sears.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2006" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data06Sears.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2007" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data07Sears.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2008" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data08Sears.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2009" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data09Sears.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
Else
If varYrA = "2010" Then
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.Mappath("Training_Delivery_Data10Sears.mdb") & ";"
SQLAdd = " SELECT * FROM Trainers WHERE Trainers.TId LIKE '%"& Request.Form("TId") &"%'"' "
Set uRS = Server.CreateObject("ADODB.Recordset")
uRS.Open SQLAdd, Connect, adOpenKeyset,adLockOptimistic
End If
End If
coachdan32