sub combo1_afterupdate() text.value=combo1.value end sub
Private Sub Combol_Change() dim rec as new adodb.recordset dim cn as new adodb.connection cn.connectionstring="provider=msdasql.1;persist security info=false;user id=用戶名;password=密碼;data source=數据庫名" cn.open rec.CursorType = adOpenDynamic rec.LockType = adLockPessimistic rec.Open "select 人員編號,姓名 from [G-人員基本資料表] where 人員編號='" & Combol.Text & "'", cn, , , adCmdTable If rec.EOF() = False Then '如果資料庫有此人員編號,則讓textbox取得相應的姓名 textbox.text = rec("姓名") Else textbox.text = "" End If rec.Close End Sub
text.value=combo1.value
end sub
dim rec as new adodb.recordset
dim cn as new adodb.connection
cn.connectionstring="provider=msdasql.1;persist security info=false;user id=用戶名;password=密碼;data source=數据庫名"
cn.open
rec.CursorType = adOpenDynamic
rec.LockType = adLockPessimistic
rec.Open "select 人員編號,姓名 from [G-人員基本資料表] where 人員編號='" & Combol.Text & "'", cn, , , adCmdTable
If rec.EOF() = False Then '如果資料庫有此人員編號,則讓textbox取得相應的姓名
textbox.text = rec("姓名")
Else
textbox.text = ""
End If
rec.Close
End Sub