我無法弄清楚我的代碼出錯了。當用戶在組合框中選擇一個值時,我希望它轉到顧問表並獲取該顧問的默認費率並將其保留在小時費率文本框中。 This is the msg that I get when I update the combobox.從組合框更新文本框的值
Private Sub cmbConsultant_Change()
Dim db As Database
Dim rs As DAO.Recordset ''Requires reference to Microsoft DAO x.x Library
Dim strSQL As String
strSQL = "defaultFee * FROM tblConsultants WHERE ID = """ & Me!cmbConsultant & """"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
If rs.RecordCount > 0 Then
Me.txtHourlyRate = rs!CountOfEndDeviceType
Else
Me.txtHourlyRate = ""
End If
Set rs = Nothing
Set db = Nothing
末次
這似乎喜歡做的事情更有效的方式,但是當我嘗試更改組合框值時,出現錯誤3464:標準表達式中的數據類型不匹配。任何想法? – Mike
是的,請參閱編輯 - 如果您的ID是數字。 – Gustav