我搜索了以前的问题,要么不明白答案,要么与我的问题略有不同。
我管理一个业务管理系统,该系统使用 MS Access 数据库(MDE 文件)。该系统本身是一个使用 ASP 页面的 Intranet 站点,是我们所有流程和程序的存储库,同时还提供了我们持续改进的系统。
我只有一般的编程能力,并且受限于无法修改 MDE 文件(创建新查询和未链接表除外)。我正在尝试增强系统并进行了一些更改,但遇到了需要帮助的障碍。
改进区域有一个高级搜索,但目前搜索只允许每个字段选择一个,例如,我可以搜索以下“新建”、“打开”、“完成”或“关闭”之一。该代码最初使用“SELECT”,我尝试将此选项更改为“SELECT Multiple”,但结果是搜索每条记录中的所有选定字段(如果我选择 New 和 Open,它只会返回两个值都为 none 的记录)
有没有办法修改多选以搜索 Selection1 OR Selection2,而不是 Selection1 AND Selection2。我也尝试了复选框,出于我的目的,这些似乎更合适,但我得到了相同的结果。
此外,选择选项会查看特定的表格和字段以填充下拉列表,我可以让复选框来做同样的事情吗?当我尝试复选框选项时,我手动命名了每个选项。
很抱歉这篇冗长的帖子,但我认为解释我想要实现的目标很容易。工作冻结了用于改进系统的资金,但仍然希望我对此有所作为,所以我正在努力学习自己。
谢谢你的帮助,莱昂。
感谢回复。我想我明白你所说的申请表是什么意思。我认为我在学习时无法正确解释(陡峭曲线)
为了进一步澄清(我希望),我已经包含了一些代码。
从搜索页面:
<!--#include file="include.asp"-->
<% Set cnnSIDB = openConn()
Set rsName = getLogin(cnnSIDB, Request.ServerVariables("LOGON_USER"))
Set rsStatus = cnnSIDB.Execute("SELECT * FROM tbl_SIDB_IR_Status")
Set rsExecutive = cnnSIDB.Execute("SELECT * FROM NASPO.dbo.NAS_tblExecutive WHERE vBranchCode = '" & Session("vBranchCode_Select") & "' ORDER BY iSortOrder")
Set rsPerson = cnnSIDB.Execute("SELECT * FROM NASPO.dbo.NAS_vPerson WHERE vBranchCode = '" & Session("vBranchCode_Select") & "' ORDER BY vLastName, vFirstName")
Set rsPosition = cnnSIDB.Execute("SELECT * FROM v_SIDB_Sponsor WHERE vBranchCode = '" & Session("vBranchCode_Select") & "' ORDER BY vPositionCode")
Set rsCategory = cnnSIDB.Execute("SELECT * FROM tbl_SIDB_IR_Category ORDER BY vCategoryDesc")
Set rsPriority = cnnSIDB.Execute("SELECT vPriority FROM tbl_SIDB_IR_Priority ORDER BY iSortOrder") %>
<HTML>
<HEAD>
<TITLE>System Improvement Proposals</TITLE>
<!--#include virtual="/include/menu_include.inc"-->
<SCRIPT language=javascript src="/calendar/calendar1.js"></script>
<script language="JavaScript" src="../include/formscripts.js"></script>
<SCRIPT language=javascript>
var cal1;
function setFocus() {
document.fSearchIR.lngIR.focus();
openPage(document.all.Processes_IR, document.all.Processes, ProcessesPic);
}
function showCalendar(objField) {
cal1 = new calendar1(objField);
cal1.year_scroll = true;
cal1.time_comp = false;
cal1.popup();
}
function submitSearchForm() {
var f ;
f = document.forms("fSearchIR") ;
f.vDelegate.value = f.lngDelegate.options[f.lngDelegate.selectedIndex].text ;
f.vOriginator.value = f.lngOriginator.options[f.lngOriginator.selectedIndex].text ;
f.vSponsor.value = f.lngSponsor.options[f.lngSponsor.selectedIndex].text ;
f.vCoord.value = f.lngCoord.options[f.lngCoord.selectedIndex].text ;
f.txtCreatedFrom.value = f.dteCreatedFrom.value;
f.txtCreatedTo.value = f.dteCreatedTo.value;
f.txtTargetFrom.value = f.dteTargetFrom.value;
f.txtTargetTo.value = f.dteTargetTo.value;
f.txtReviewFrom.value = f.dteReviewFrom.value;
f.txtReviewTo.value = f.dteReviewTo.value;
f.submit();
}
function resetForm() {
var f ;
f = document.forms("fSearchIR") ;
document.frames("fSponsorPerson").location.href = "http://<%=Application("HOME")%>/Standing_Instructions/fSponsorPerson.asp?PositionID=0" ;
f.reset() ;
}
function getSponsorPerson() {
document.frames("fSponsorPerson").location.href = "http://<%=Application("HOME")%>/Standing_Instructions/fSponsorPerson.asp?PositionID=" + document.all.lngSponsor.value ;
}
</SCRIPT>
</head>
<BODY topmargin=0 leftmargin=0 bgcolor=white onLoad="setFocus()">
<!--#include virtual="/include/menu.inc"-->
<TABLE class=clsText width=100% cellspacing=0 cellpadding=3 align=center>
<TR><TD class=clsPageHeading width=20></TD>
<TD class=clsPageHeading valign=top>Search SIP Database</TD>
<TD class=clsPageHeading align=right valign=top>
<INPUT class=clsReturn type=button value="RETURN" onClick="location.href='default_IR.asp'"></TD></TR>
</TABLE>
<BR><BR>
<!-- top of photo frame -->
<TABLE border=0 align=center cellpadding=0 cellspacing=0 width=75% class=clsText>
<TR>
<TD width=22><IMG src="/images/photo_topleft.gif" width=22 height=42></TD>
<TD background="/images/photo_top.gif"><IMG src="/images/photo_top_heading_search.gif" width=260 height=42></TD>
<TD width=30><IMG src="/images/photo_topright.gif" width=30 height=42></TD></TR>
<TR>
<TD width=22 background="/images/photo_left.gif"></TD>
<TD valign=top>
<!-- ====================== SEARCH Form starts here ================================= -->
<TABLE border=0 class=clsText width=100% align=center>
<FORM name=fSearchIR action="http://<%=Application("HOME")%>/Standing_Instructions/listIR.asp" method=post>
<INPUT type=hidden name=SEARCH value=1>
<INPUT type=hidden name=listIR_return value="searchIR.asp">
<INPUT type=hidden name=vDelegate>
<INPUT type=hidden name=vOriginator>
<INPUT type=hidden name=vSponsor>
<INPUT type=hidden name=vCoord>
<INPUT type=hidden name=vRelatedArea>
<INPUT type=hidden name=txtCreatedFrom>
<INPUT type=hidden name=txtCreatedTo>
<INPUT type=hidden name=txtTargetFrom>
<INPUT type=hidden name=txtTargetTo>
<INPUT type=hidden name=txtReviewFrom>
<INPUT type=hidden name=txtReviewTo>
********* some more code *************
<TR>
<TD colspan=3></TD></TR>
<TR>
<TD width=10> </TD>
<TD>SIP #</TD>
<TD><INPUT class=clsText type=text name=lngIR size=11></TD></TR>
<TR>
<TD width=10> </TD>
<TD>Subject</TD>
<TD><INPUT class=clsText type=text name=vSubject size=40></TD></TR>
<TR>
<TD width=10> </TD>
<TD>Status</TD>
<TD><SELECT name=vStatus class=clsText>
<OPTION value="" selected></OPTION>
<% Do Until rsStatus.EOF %>
<OPTION value="<%=rsStatus("vStatus")%>"><%=rsStatus("vStatusDesc")%></OPTION>
<% rsStatus.MoveNext
Loop %>
</SELECT></TD></TR>
然后在下一页“ListIR.asp”这是代码:
<!--#include file="include.asp"-->
<% listIR_return = Request.Form("listIR_return")
If Not listIR_return > "" Then listIR_return = "default_IR.asp"
Set cnnSIDB = openConn()
Set rsName = getLogin(cnnSIDB, Request.ServerVariables("LOGON_USER"))
Set rsIR = Server.CreateObject("ADODB.Recordset")
If Request.Form("SEARCH") = 1 Then
If Request.Form("lngIR") > "" Then
If strWhere > "" Then
strWhere = strWhere & " AND "
strDesc = strDesc & " AND "
End If
strWhere = strWhere & "lngIR = " & Request.Form("lngIR")
strDesc = strDesc & "SIP # = " & Request.Form("lngIR")
End If
If Request.Form("vSubject") > "" Then
If strWhere > "" Then
strWhere = strWhere & " AND "
strDesc = strDesc & " AND "
End If
strWhere = strWhere & "vSubject LIKE '%" & Request.Form("vSubject") & "%'"
strDesc = strDesc & "Subject LIKE '" & Request.Form("vSubject") & "'"
End If
If Request.Form("vSICode") > "" Then
If strWhere > "" Then
strWhere = strWhere & " AND "
strDesc = strDesc & " AND "
End If
strWhere = strWhere & "vSICode = '" & Request.Form("vSICode") & "'"
strDesc = strDesc & "SICode = '" & Request.Form("vSICode") & "'"
End If
If Request.Form("lngDelegate") > "" Then
If strWhere > "" Then
strWhere = strWhere & " AND "
strDesc = strDesc & " AND "
End If
strWhere = strWhere & "lngDelegate = " & Request.Form("lngDelegate")
strDesc = strDesc & "Delegate = " & Request.Form("vDelegate")
End If
If Request.Form("lngOriginator") > "" Then
If strWhere > "" Then
strWhere = strWhere & " AND "
strDesc = strDesc & " AND "
End If
strWhere = strWhere & "lngOriginator = " & Request.Form("lngOriginator")
strDesc = strDesc & "Originator = " & Request.Form("vOriginator")
End If
If Request.Form("vOrigArea") > "" Then
If strWhere > "" Then
strWhere = strWhere & " AND "
strDesc = strDesc & " AND "
End If
strWhere = strWhere & "vOriginatorExecutive = '" & Request.Form("vOrigArea") & "'"
strDesc = strDesc & "Originating Area = '" & Request.Form("vOrigArea") & "'"
End If
If Request.Form("vExecutiveCode") > "" Then
If strWhere > "" Then
strWhere = strWhere & " AND "
strDesc = strDesc & " AND "
End If
strWhere = strWhere & "vDelegateExecutive = '" & Request.Form("vExecutiveCode") & "'"
strDesc = strDesc & "Related Area = '" & Request.Form("vExecutiveCode") & "'"
End If
If Request.Form("vPriority") > "" Then
If strWhere > "" Then
strWhere = strWhere & " AND "
strDesc = strDesc & " AND "
End If
strWhere = strWhere & "vPriority = '" & Request.Form("vPriority") & "'"
strDesc = strDesc & "Priority = '" & Request.Form("vPriority") & "'"
End If
If Request.Form("lngSponsor") > "" Then
If strWhere > "" Then
strWhere = strWhere & " AND "
strDesc = strDesc & " AND "
End If
strWhere = strWhere & "lngSponsor = " & Request.Form("lngSponsor")
strDesc = strDesc & "Sponsor = " & Request.Form("vSponsor")
End If
If Request.Form("lngCoord") > "" Then
If strWhere > "" Then
strWhere = strWhere & " AND "
strDesc = strDesc & " AND "
End If
strWhere = strWhere & "lngCoord = " & Request.Form("lngCoord")
strDesc = strDesc & "Coord = " & Request.Form("vCoord")
End If
If Request.Form("vStatus") > "" Then
If strWhere > "" Then
strWhere = strWhere & " AND "
strDesc = strDesc & " AND "
End If
strWhere = strWhere & "vStatus = '" & Request.Form("vStatus") & "'"
strDesc = strDesc & "Status = '" & Request.Form("vStatus") & "'"
End If
*********** at the end of this page it has this code ********
<% If strDesc > "" Then %>
<TABLE border=0 width=100% class=clsVerdana9>
<TR height=7><TD></TD></TR>
<TR><TD><B>Search Criteria: <FONT color=red><%=strDesc%></FONT></B></TD></TR>
</TABLE>
<% End If %>
<% If rsIR.EOF Then %>
<P class=clsText align=center>
There were no System Improvement Proposals matching your search criteria.
<BR><BR>
Please return to the <A href="http://<%=Application("HOME")%>/Standing_Instructions/searchIR.asp" class=bluered>Search Page</A> to refine your search.
</P>
<TABLE border=0 width=100%>
<% Else %>
<TABLE border=0 width=100% cellspacing=0 cellpadding=2 class=clsVerdana8>
<TR height=107>
<TD colspan=8 height="107"></TD>
</TR>
<TR bgcolor="#CCCCCC" height=1>
<TD colspan=8></TD>
</TR>
<TR bgcolor="#DDDDDD">
<TD width=40>SIP#</TD>
<TD>Subject</TD>
<TD width=157>Delegate</TD>
<td width=114>Priority</td>
<td width=60 align=right>Created</td>
<td width=60 align=right>Target</td>
<TD width=50 align=center>Status</TD>
<TD width=60 align=right>Date</TD>
</TR>
<TR bgcolor="#CCCCCC" height=1>
<TD colspan=8></TD>
</TR>
<% bAltRow = true
Do Until rsIR.EOF %>
<FORM name="fViewIR_<%=rsIR("lngIR")%>" action="http://<%=Application("HOME")%>/Standing_Instructions/viewIR.asp" method=post target="_parent">
<INPUT type=hidden name=viewIR_return value="listIR.asp">
<INPUT type=hidden name=listIR_return value="<%=listIR_return%>">
<INPUT type=hidden name=strWhere value="<%=strWhere%>">
<INPUT type=hidden name=strDesc value="<%=strDesc%>">
<INPUT type=hidden name="lngIR" value="<%=rsIR("lngIR")%>">
</FORM>
<% If bAltRow Then
Response.Write "<TR class=clsText>"
Else
Response.Write "<TR class=clsText2>"
End If
bAltRow = Not bAltRow %>
<TD><%=rsIR("lngIR")%></TD>
<TD><A href="javascript:fViewIR_<%=rsIR("lngIR")%>.submit()" class=bluered><%=rsIR("vSubject")%></A></TD>
<TD width="157"><A href="/employee.asp?ID=<%=rsIR("lngDelegate")%>" class=navyred><font size="1"><%=rsIR("vDelegate")%></font></A<</TD>
<TD width="114"><font size="1"><%=rsIR("vPriority")%></font></TD>
<TD align=right><font size="1"><%=formatDate(rsIR("dteCreated"),2)%></font></TD>
<TD align=right><font size="1"><%=formatDate(rsIR("dteTarget"),2)%></font></TD>
<TD align=center><font size="1"><%=rsIR("vStatus")%></font></TD>
<TD align=right><font size="1"><%=formatDate(rsIR("dteStatus"),2)%></font></TD>
</TR>
<TR bgcolor="#CCCCCC" height=1>
<TD colspan=8></TD>
</TR>
<% rsIR.MoveNext
Loop
End If %>
</TABLE>
</td></tr>
</table>
</body>
<%
rsName.Close
Set rsName = Nothing
rsIR.Close
Set rsIR = Nothing
cnnSIDB.Close
Set cnnSIDB = Nothing
%>
</html>
抱歉,如果这太长了,或者我已经填满了格式。任何帮助,将不胜感激。
更新 -
嗨,我一直在研究这两页,并认为我理解他们在做什么。第一个页面收集用户输入,第二个页面,主要是看起来像我上次发布的最后一个代码块的区域,获取用户输入并将其添加到页面下方的此字符串中。
strSQL = "SELECT * FROM v_SIDB_IR_ALL " & strWhere & " ORDER BY lngSortOrder, lngIR DESC"
我玩过 IN 和 AND 选项,并将 vStatus 代码移动到代码的底部或顶部(认为它可能无法正常工作,因为“IN”被放置在字符串的错误末端/区域)但这会导致页面错误无法加载页面,或者导致页面出现我的初始问题或页面返回所有内容。
我不知道现在该去哪里
莱昂