CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 FUTILE: wrong selection for dynamic listbox

Print topic Send  topic

Author Message
ryan
Posted: 03/14/2002, 1:49 AM

The dynamic listbox is a very good article
however it does NOT satisfy me this is what I would like

ON GRID FORM

[Company] [Project (click to edit)]
Company 1 Project 1 for Co 1
Company 1 Project 2 for Co 1
Company 2 Project 1 for Co 2
Company 3 Project 1 for Co 3

When I click Project 1 for Co 1

Listbox 1 : Company 1
Project : Project 1 for Co 1

When I click Project 1 for Co 2

Listbox 1 : Company 1
Project : Project 1 for Co 2

When I click Project 1 for Co 3

Listbox 1 : Company 1
Project : Project 1 for Co 3

That means everytime I click the project
for updating IT ALWAYS LOADS COMPANY 1 and when I press
update it takes all projects belonging to Co 1
as the FIRST RECORD defined in the database

My concern is users will ASSIGN WRONG
PROJECTS TO WRONG COMPANIES w/c is
MESSY and UNPROFESSIONAL.

here is the Custom Show on w/c I fail
to solve please help.

- - - - -
'-------------------------------
Dim sWhere : sWhere = ""
Dim sFormTitle: sFormTitle = "Assign Company Projects"
Dim bPK : bPK = True

'-------------------------------
' Load primary key and form parameters
'-------------------------------
if sadsErr = "" then
fldP_LoginID = GetParam("P_LoginID")
fldP_UserID = GetParam("P_UserID")
SetVar "Trn_P_LoginID", GetParam("P_LoginID")
SetVar "Rqd_P_LoginID", GetParam("P_LoginID")
pField1 = GetParam("P_UserID")
SetVar "adsError", ""
else
fldField1 = GetParam("Field1")
fldProjectID = GetParam("ProjectID")
fldPrj_Milestone = GetParam("Prj_Milestone")
SetVar "Rqd_P_LoginID", GetParam("Rqd_P_LoginID")
fldP_LoginID = GetParam("Trn_P_LoginID")
SetVar "Trn_P_LoginID", GetParam("Trn_P_LoginID")
pField1 = GetParam("PK_P_UserID")
SetVar "sadsErr", sadsErr
SetVar "FormTitle", sFormTitle
Parse "adsError", False
end if
'-------------------------------

'-------------------------------
' Load all form fields

'-------------------------------

'-------------------------------
' Build WHERE statement

if IsEmpty(pField1) then bPK = False

sWhere = sWhere & "P_UserID=" & ToSQL(pField1, "Number")
SetVar "PK_Field1", pField1
'-------------------------------
'-------------------------------
' ads Open Event begin
sqls_ = "SELECT P_Company.P_CompanyID as catid, P_Company.P_CompanyName as catname FROM P_Company "

set rs = cn.execute(sqls_)
set subrs = Server.CreateObject("ADODB.Recordset")

while not rs.eof


set subrs = cn.execute ("select P_ProjectID as Prj_Milestone,P_ProjectDescription as name from [P_Project] where P_CompanyID= " & rs(0) )

while not subrs.eof
name = subrs(1)
id = subrs(0)
subrs.MoveNext
if subrs.eof then
SetVar "subcat" , """" & name & "#" & id & """"
else
SetVar "subcat" , """" & name & "#" & id & ""","
end if
Parse "subcats",true
wend
subrs.close

' if cstr(GetValue(rsProjectID, 0)) = cstr(fldProjectID) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
'response.write cstr(fldProjectID)
SetVar "cat" , rs(1) & "#" & rs(0)
Parse "cats",true
SetVar "subcats",""
rs.MoveNext
wend

rs.close
' ads Open Event end
'-------------------------------

SetVar "FormTitle", sFormTitle

'-------------------------------
' Build SQL statement and open recordset
'-------------------------------
sSQL = "select * from P_SystemUsers where " & sWhere
openrs rs, sSQL
bIsUpdateMode = (bPK and not(sAction = "insert" and sForm = "ads") and not rs.eof)
'-------------------------------

'-------------------------------
' Load all fields into variables from recordset or input parameters
'-------------------------------
if bIsUpdateMode then
fldP_LoginID = GetValue(rs, "P_LoginID")
fldField1 = GetValue(rs, "P_UserID")

'-------------------------------
' Load data from recordset when form displayed first time
'-------------------------------
if sadsErr = "" then
fldProjectID = GetValue(rs, "P_CompanyID")
fldPrj_Milestone = GetValue(rs, "P_ProjectID")
end if
SetVar "adsInsert", ""
Parse "adsEdit", False
else
if sadsErr = "" then
fldField1 = ToHTML(GetParam("P_UserID"))
fldP_LoginID = ToHTML(GetParam("P_LoginID"))
end if
SetVar "adsEdit", ""
Parse "adsInsert", False
end if
Parse "adsCancel", false

'-------------------------------
' Set lookup fields
'-------------------------------
fldP_LoginID = DLookUp("P_Login", "P_LoginName", "P_LoginID=" & ToSQL(fldP_LoginID, "Number"))

'-------------------------------
' Show form field
'-------------------------------
SetVar "Field1", ToHTML(fldField1)
SetVar "P_LoginID", ToHTML(fldP_LoginID)
SetVar "adsLBProjectID", ""
LOV = Split("1;", ";")
if (ubound(LOV) mod 2) = 1 then
for i = 0 to ubound(LOV) step 2
SetVar "ID", LOV(i) : SetVar "Value", LOV(i+1)
if cstr(LOV(i)) = cstr(fldProjectID) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
Parse "adsLBProjectID", True
next
end if

SetVar "adsLBPrj_Milestone", ""
LOV = Split("1;", ";")
if (ubound(LOV) mod 2) = 1 then
for i = 0 to ubound(LOV) step 2
SetVar "ID", LOV(i) : SetVar "Value", LOV(i+1)
if cstr(LOV(i)) = cstr(fldPrj_Milestone) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
Parse "adsLBPrj_Milestone", True
next
end if

Parse "Formads", False


Set rs = Nothing

'-------------------------------
- - - - -
Alex Alexapolsky
Posted: 03/14/2002, 2:30 AM

There is another example in gotocode.com/artlist.asp

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.