以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]下拉菜单想传递个参数,应该在那里写代码  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=177062)

--  作者:2900819580
--  发布时间:2022/5/7 23:58:00
--  [求助]下拉菜单想传递个参数,应该在那里写代码
1、全局中声明变量_BmNmae


2、以下为下拉窗体的DropDownOpened代码 想问,我想在下拉窗体要打开时增加一个参数,应该在设置下拉的Table那里写代码:BmNmae = “销售部”。
Dim txt As String = e.Form.DropDownBox.Text
Dim tb As Table = Tables(e.Form.Name & "_table1")
Dim dt As DataTable = tb.DataTable 
\'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Sele ct * from {UseGl} where FID = 1 and BmName = \'" & _BmNmae & "\'" 
If txt > "" Then
    txt = "\'%" & txt & "%\'"
    cmd.CommandText &= " ( username Like " & txt & " Or bmname Like " & txt & " )"
End If
\'MessageBox.Show(cmd.CommandText)
\'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tb.DataSource = cmd.ExecuteReader
tb.SetColVisibleWidth("Itid|88|BmName|88|UseName|88")
tb.AutoSizeCols
e.Form.DropDownBox.Select() \'将输入焦点返回下拉列表框
[此贴子已经被作者于2022/5/7 23:58:06编辑过]

--  作者:有点蓝
--  发布时间:2022/5/8 20:36:00
--  
目的是什么?如果是要根据不同的table设置不同的值,应该就到DropDownOpened代码处理

if e.Form.DropTable.name = “表A”
_BmNmae= “销售部”
endif
Dim txt As String = e.Form.DropDownBox.Text
Dim tb As Table = Tables(e.Form.Name & "_table1")
Dim dt As DataTable = tb.DataTable 
\'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Sele ct * from {UseGl} where FID = 1 and BmName = \'" & _BmNmae & "\'" 

--  作者:2900819580
--  发布时间:2022/5/9 16:48:00
--  
老师,谢谢,上面的问题解决了,

另一个新的问题,BOM中有二列,一个是新料号,一个是旧料号,现在需要新旧料号共存,所以物料表也做了新旧料号,
BOM新旧料号下拉设置,但是以下代码,只能返回料号,如何可以判断是从旧料号打开的下拉窗体就返回旧料号,从料号打开的就返回新料号
tb.Cols("料号").DropForm = "物料表查询"
tb.Cols("旧料号").DropForm = "物料表查询"

If e.Selected Then \'如果选择了值
Dim tbl As Table = Tables(e.Form.Name & "_Table1")
    If tbl.Current IsNot Nothing Then
     如果是料号下拉打开的话   e.Form.DropDownBox.Value = tbl.Current("料号")
     如果是旧料号下拉打开的话   e.Form.DropDownBox.Value = tbl.Current("旧料号")
        If e.Form.DropTable IsNot Nothing Then \'如果是通过表下拉的
            e.Form.DropTable.FinishEditing() 
        Else \'如果是通过窗口下拉的
            e.Form.DropDownBox.WriteValue() 
        End If
    End If
End If

--  作者:有点蓝
--  发布时间:2022/5/9 17:01:00
--  
判断DropColhttp://www.foxtable.com/webhelp/topics/2705.htm

if e.Form.DropCol.name = "料号" then
e.Form.DropDownBox.Value = tbl.Current("料号")