Private Sub 查找_Click()
Dim rst1 As Recordset
Dim temp As String
strsearchname = InputBox("輸入要查找的工號", "查找輸入")
temp = " select * from 員工資訊表 where 工號 like '" & strsearchname & " '"
Set rst1 = db.OpenRecordset(temp)
If rst1.EOF Then
Do While rst1.EOF
MsgBox "找到了!"
工號.Value = rst1("工號")
姓名.Value = rst1("姓名")
崗位.Value = rst1("崗位")
薪金.Value = rst1("薪金")
工齡.Value = rst1("工齡")
附注.Value = rst1("附注")
rst1.MoveNext
Loop
Else
MsgBox "沒找到"
End If
rst1.Close
End Sub
好吧,我是新手,昨天才接觸Access , 照著書上一筆一劃打的,為何不能用呢....
uj5u.com熱心網友回復:
試試看以下3種temp = " select * from 員工資訊表 where 工號 = '" & strsearchname & "'"
temp = " select * from 員工資訊表 where 工號 = " & strsearchname & '"
temp = " select * from 員工資訊表 where 工號 like '%" & strsearchname & "%'"
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/119348.html
標籤:VBA
上一篇:excel滾動條怎么設定
