|
3#
楼主 |
发表于 2010-5-8 22:01:02
|
只看该作者
本帖最后由 lvjiantuzhu 于 2010-5-8 23:16 编辑
我用遍历列名的方法实现了我想要的功能,下面是代码,不知道有没有更简便的函数能直接定位某一列的数据!
Private Sub aaa_DblClick(Cancel As Integer)
Select Case Me.查看窗口参数ID
Case 1
Case Else
Dim rs As Recordset
Set rs = Me.RecordsetClone
Dim rs1 As New ADODB.Recordset
If Not Me.链接表参数ID1 = 1 Then
rs1.Open Me.链接表名称.Value, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
For i = 0 To rs.Fields.Count - 1
If Me.链接项 = rs.Fields(i).Name Then
rs1.Find "[" & Me.链接项 & "]=" & str(rs.Fields(i).Value)
If Not rs1.EOF Then
For j = 0 To rs1.Fields.Count - 1
If Me.数据ID项 = rs1.Fields(j).Name Then
DoCmd.OpenForm Me.窗口名称, , , , , , rs1.Fields(j).Value
Exit For
End If
Next
End If
Exit For
End If
Next
Else
For i = 0 To rs.Fields.Count - 1
If Me.数据ID项 = rs.Fields(i).Name Then
rs.Bookmark = Me.Bookmark
DoCmd.OpenForm Me.窗口名称, , , , , , rs.Fields(i).Value
Exit For
End If
Next
End If
End Select
End Sub |
|