我一直从搜索组合框中获取输入参数值。我检查了所有拼写,但缺乏解决问题的知识。有人可以帮忙吗?
下面重点介绍 -
Me.tbl_detailsubform1.Form.Requery
代码:
Me.tbl_detailsubform1.Form.RecordSource = Task:
Function SearchCriteria()
Dim PN As String
Dim SN As String
Dim Task As String
Dim strCriteria As String
If IsNull(Me.cboProduct) Then
PN = "[Product] like '*'"
Else
PN = "[Product] = " & Me.cboProduct & ""
End If
If IsNull(Me.cboSerial) Then
SN = "[Serial] like '*'"
Else
SN = "[Serial] = " & Me.cboSerial & ""
End If
strCriteria = PN & " And " & SN
Task = "SELECT * FROM tbl_StockOut where " & strCriteria & " Order by PN asc"
Me.tbl_detailsubform1.Form.RecordSource = Task
Me.tbl_detailsubform1.Form.Requery
Me.Text89 = findRecordCount(Task)
If Me.Text89 = 0 Then
MsgBox "No Record Found!", vbInformation, "Search Result"
End If
End Function
答案 0 :(得分:0)
假设[Product]
和[Serial]
都是文本字段...
Debug.Print strCriteria
,您可能需要执行以下操作:
If IsNull(Me.cboProduct) Then
PN = "[Product] like '*'"
Else
PN = "[Product] = " & Chr(34) & Me.cboProduct & Chr(34)
End If
If IsNull(Me.cboSerial) Then
SN = "[Serial] like '*'"
Else
SN = "[Serial] = " & Chr(34) & Me.cboSerial & Chr(34)
End If
要么是该字段,要么字段PN不存在,但您的SELECT *不应引起问题。