Private Sub Command1_Click()
Dim adocn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSql As String
strSql = "select * from 表名 where 字段名=" & 名字
adocn.Open
rs.Open strSql, adocn, 3, 3
If rs.EOF And rs.BOF Then
Set rs = Nothing
adocn.Close
MsgBox "查无信息", vbCritical + vbOKOnly, "信息"
Exit Sub
Else
Text1.Text = rs.Fields("想要显示字段名项目")
rs.Close
Set rs = Nothing
adocn.Close
End If
End Sub