Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Else From Statement... Overwrite

Status
Not open for further replies.

vb89

MIS
Aug 21, 2008
47
US
(This is a classic asp page pulling data from an oracle database) I basically just want the first if statement to overwrite the second statement in the case that the criteria of the first if statement is met. So basically if the league_id value is 0 and the team id value is 0 I would like the tSQL function to display main.cfb_division_id = 1" and - Division: I-A"...any help on how to edit my code to do that would be great...thanks


Code:
        If iLeagueID = "0" and iTeamID = "0" then
    	tSQL = tSQL & " AND main.cfb_division_id = 1"
		tPlayerFilter = tPlayerFilter & " - Division: I-A"
        End If 
 
	    If iLeagueID = "0"  Then
	    tSQL = tSQL
        tPlayerFilter = tPlayerFilter 
		ElseIf iLeagueID = "2" Then
     	tSQL = tSQL & " AND main.cfb_division_id = 2"
	 	tPlayerFilter = tPlayerFilter & " - Division: I-AA"
		ElseIf iLeagueID = "9" Then
		tSQL = tSQL & " AND main.cfb_division_id = 9"
		tPlayerFilter = tPlayerFilter & " - Division: I-A + I-AA"
     	ElseIf iLeagueID = "1" Then
    	tSQL = tSQL & " AND main.cfb_division_id = 1"
		tPlayerFilter = tPlayerFilter & " - Division: I-A"
		End If

The value of league_id along with other filter(TeamId, etc) decides what is going to be displayed on the page, I want the following to happen: If league_id and team_id filters are both unselected (so basically value = "0") I want league_id to display main.cfb_division_id = 1" otherwise if team_id has a value I want league_id to remain with a value of "0"...hope this clarify's

and incase it help's, here's the code that set's the other filters...
Code:
  'Add Team/Conference Filter
   If iTeamID <> "" Then
  	 tSQL = tSQL & " AND main.team_id =" & iTeamID
	 tPlayerFilter = tPlayerFilter & " - Team:" & tTeamName
   ElseIf iConfID <> "" Then
     tSQL = tSQL & " AND main.conference_id =" & iConfID
	 tPlayerFilter = tPlayerFilter & " - Conf:" & tConfName
   End If
 
The construct would be
Code:
If iLeagueID = "0" and iTeamID = "0" then
        tSQL = tSQL & " AND main.cfb_division_id = 1"
        tPlayerFilter = tPlayerFilter & " - Division: I-A"
 Else
      If iLeagueID = "0"  Then
        tSQL = tSQL
        tPlayerFilter = tPlayerFilter 
      ElseIf iLeagueID = "2" Then
         tSQL = tSQL & " AND main.cfb_division_id = 2"
         tPlayerFilter = tPlayerFilter & " - Division: I-AA"
      ElseIf iLeagueID = "9" Then
        tSQL = tSQL & " AND main.cfb_division_id = 9"
        tPlayerFilter = tPlayerFilter & " - Division: I-A + I-AA"
       ElseIf iLeagueID = "1" Then
        tSQL = tSQL & " AND main.cfb_division_id = 1"
        tPlayerFilter = tPlayerFilter & " - Division: I-A"
        End If
End If


Paul
 
yeah I tried that...unfortunatly it didn't do the job, any other suggestions?

I also tried :
Code:
If iLeagueID = "0" and iTeamID = "0" then 
    	tSQL = tSQL & " AND main.cfb_division_id = 1" 
    	tPlayerFilter = tPlayerFilter & " - Division: I-A" 
    	leagueAndTeamProcessed = True 
    End If 

	If leagueAndTeamProcessed = False Then 
    	If iLeagueID = "0" Then 
        	tSQL = tSQL 
        	tPlayerFilter = tPlayerFilter 
    	ElseIf iLeagueID = "2" Then 
        	tSQL = tSQL & " AND main.cfb_division_id = 2" 
        	tPlayerFilter = tPlayerFilter & " - Division: I-AA" 
    	ElseIf iLeagueID = "9" Then 
       		tSQL = tSQL & " AND main.cfb_division_id = 9" 
        	tPlayerFilter = tPlayerFilter & " - Division: I-A + I-AA" 
    	ElseIf iLeagueID = "1" Then 
        	tSQL = tSQL & " AND main.cfb_division_id = 1" 
        	tPlayerFilter = tPlayerFilter & " - Division: I-A" 
    	End If 
	End If
 
If league_id and team_id filters are both unselected (so basically value = "0")
Have you tested the values to see if they are correct. "0" indicates a text value to me, not a boolean value which is what True and False are. Null (they didn't fill anything in for those fields) would return something else. It may be you are not testing the correct return value.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top