|
我的数据库中,card字段由原来的number改为Text,我在输入card时,原来由可以自动选择Name,现在老是提示这句出错.Set rsMat = dbs.OpenRecordset(strTemp),请高手指点,万分感谢!!
Private Sub Card_LostFocus()
Dim inRowcount As Integer
Dim strMsg As String
If Not IsNull(Me![Name]) Then
Exit Sub
End If
Set dbs = CurrentDb
If IsNull(Me![Card]) Or Not IsNull(Trim(Me![Name])) Then
Exit Sub
End If
strTemp = "select card, name from [basic information] where card=" & Str(Me![Card])
'MsgBox strTemp
With dbs
Set rsMat = dbs.OpenRecordset(strTemp)
inRowcount = rsMat.RecordCount
' MsgBox "Row count:" + Str(inRowcount)
If inRowcount = 0 Then
strMsg = "Card " + Str(Me![Card]) + " does not exist"
MsgBox strMsg
Else
With rsMat
Me![Name] = .Fields("name")
End With
End If
rsMat.Close
End With
dbs.Close
End Sub |
|