Office中国论坛/Access中国论坛

标题: 以下代码何解 [打印本页]

作者: tonywong    时间: 2005-11-4 00:08
标题: 以下代码何解
Private Sub lvwList_DblClick()  'LvwList是一个listView控件

On Error GoTo Exit_Err

  

  If lvwList.SelectedItem Is Nothing Then Exit Sub

  

  Dim ID As Long

  Dim sSQL As String

  Dim rs As DAO.Recordset

  

  ID = CLng(Mid(lvwList.SelectedItem.Key, 3))

  sSQL = "SELECT TINFO.FM, TINFO.TO, TINFO.SJ, TINFO.INFO, TINFO.WDT FROM TINFO WHERE TINFO.ID=" & ID & " Order by TINFO.WDT DESC;"

  Set rs = CurrentDb.OpenRecordset(sSQL, , dbPessimistic)

  

  sSQL = "主    题:" & rs!SJ & vbCrLf & "发 件 人:" & rs!FM & vbCrLf & "收 件 人:" & rs!TO & vbCrLf & "时    间:" & rs!wdt _

      & vbCrLf & vbCrLf & "=======================================================================================" _

      & vbCrLf & vbCrLf & rs!INFO

  rs.Close

  Set rs = Nothing

  

  DoCmd.OpenForm "frmRead"

  Forms!frmRead.INFO = sSQL

  Forms!frmRead.cmdfocus.SetFocus

  

  Exit Sub

Exit_Err:

  MsgBox "Error!" & Err.Number & vbCrLf & Err.Description

  Exit Sub

  

End Sub



以上代码ID = CLng(Mid(lvwList.SelectedItem.Key, 3))何解,为什么把3改为其他值就是出错.








欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3