以文本方式查看主题

-  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=127916)

--  作者:xuxingbo
--  发布时间:2018/11/25 1:01:00
--  [求助]查找及定位的问题
窗口上有一个组合框(CBX)下拉菜单有选项,我想在选择组合框里面内容时自动找到对应内容的列,窗口上其他有绑定的文本框就可以显示数据,怎么实现

Dim Val As String = e.Form.Controls("cbx")
Dim Index As Integer
With CurrentTable
    Index = .FindRow(.Cols(.ColSel).Name & " = \'" & Val & "\'", .Position + 1,True)
    If Index >= 0 Then
        .Position = Index
    End If
End With

这个代码怎么错的

--  作者:y2287958
--  发布时间:2018/11/25 9:44:00
--  
组合框”的列表项目是什么?列名?
--  作者:有点甜
--  发布时间:2018/11/25 17:03:00
--  

代码没问题,报什么错?如果你选中的是数值列、日期列、逻辑列(非字符列),有可能报错,这个时候改成

 

Dim Val As String = 2 = e.Form.Controls("cbx")
Dim Index As Integer
With CurrentTable
    Index = .FindRow("convert(" & .Cols(.ColSel).Name & ",\'System.String\') = \'" & Val & "\'", .Position + 1,True)
    If Index >= 0 Then
        .Position = Index
    End If
End With