运行时提示“标准表达式中的数据类型不匹配”
代码为:
Private Sub dataGrid1_Click()
Dim strName As Long
Dim strsql As String
Dim rsttmp As New ADODB.Recordset
'点击的是第一行或超出最大行时退出
If dataGrid1.Row = 0 Or dataGrid1.Row > dataGrid1.Rows - 1 Then Exit Sub
strName = dataGrid1.TextMatrix(dataGrid1.Row, 1)
If Trim(strName) = "" Then Exit Sub
strsql = "select * from 通讯录 Where id='" & strName & "'"
rsttmp.Open strsql, conn, adOpenKeyset, adLockOptimistic
If rsttmp.RecordCount = 1 Then
rsttmp.MoveFirst
txtName.Text = Trim("" & rsttmp!姓名)
txtTel.Text = Trim("" & rsttmp!联系方式)
txtAddress.Text = Trim("" & rsttmp!地址)
txtclass.Text = Trim("" & rsttmp!类别)
txtRemark.Text = Trim("" & rsttmp!备注)
id.Text = Trim("" & rsttmp!id)
End If