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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use different Querystring based on session value

Status
Not open for further replies.

robbie59

Technical User
May 9, 2001
36
US
I have an existing query as follows:

SELECT state, JobNumber, DictatorName, DictatorID, AssignTranID, dtComplete, dtAtTran, JobLength, lExtraStatus, iPriorityLevel
FROM Dictations
WHERE DictatorName like 'vardictator' AND state Like 'varradio' and AssignTranID like 'vartran'

Vartran's parameter value is the session value I would like to use a listmenu by the name of tranid as the vartran parameter if the session value is % if anything other than % is the session value I would like to just use the session value as the parameter.

this may be easy but it has me stumped...

Thanks for any help

If knowledge were power I would be a AAA battery!
 
assuming your session value is stored as "vartran" then:
Code:
dim sTran, sql

if session("vartran") = "%" then
	sTran = request("tranid")
else
	sTran = session("vartran")
end if

sql = "SELECT state, JobNumber, DictatorName, DictatorID, AssignTranID," &_
	" dtComplete, dtAtTran, JobLength, lExtraStatus, iPriorityLevel" &_
	" FROM Dictations" &_
	" WHERE DictatorName LIKE 'vardictator' AND state LIKE 'varradio'" &_
	" AND AssignTranID LIKE '" & sTran & "'

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
The session is (Session("Accesslevel"))

I use dreamweaver and vartran is a variable and the runtime value is currently set to (Session("Accesslevel")) I basically don't want to use (Session("Accesslevel")) as the runtime value if the session value is % I want to use tranid as the runtime value if it is %


Thanks for the help

If knowledge were power I would be a AAA battery!
 
Code:
if rtrim(session("Accesslevel")) = "%" then
    sTran = request.form("tranid")
else
    sTran = session("vartran")
end if

rest the same.

IMHO it is a little strange to see a SQL statement with a field LIKE 'value'; isn't it the same as field = 'value'? But it is a nice trick for the last part:
" AND AssignTranID LIKE '" & sTran & "'
The alternative is

Code:
sql = "SELECT state, JobNumber, DictatorName, " &_
"DictatorID, AssignTranID, dtComplete, dtAtTran, " &_
"JobLength,lExtraStatus, iPriorityLevel " &_
"FROM Dictations " &_
"WHERE DictatorName = 'vardictator' " &_
"AND state = 'varradio'" 

if sTran <> &quot;%&quot; then
    sql = sql & &quot; AND AssignTranID = '&quot; & sTran & &quot;'
end if

hth,
Foxbox
ttmug.gif
 
I am using dreamweaver,s recordset builder screen so where do I put the code or what portion of code goes where or should I make this a stored procedure and call it

If knowledge were power I would be a AAA battery!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top