|
论坛里面关于查询代码的例子多如浩海,我的水平有限,于是将自己看的懂的一些查询代码合成了一个例子.但总是报错.希望高手能够帮助解答一下.另外是否能推荐一些相关的书籍的.谢谢
Private Sub CmdQuery_Click()
Dim strWhere As String
strWhere = "True"
If Nz(Me.SAP_No, "") <> "" Then strWhere = strWhere & " AND [SAP No] Like ""*" & Me.SAP_No & "*"""
If Nz(Me.Storage_bin, "") <> "" Then strWhere = strWhere & " AND [Storage bin] Like ""*" & Me.Storage_bin & "*"""
If Nz(Me.Material, "") <> "" Then strWhere = strWhere & " AND [Material] Like ""*" & Me.Material & "*"""
If Nz(Me.Spec, "") <> "" Then strWhere = strWhere & " AND [Spec] Like ""*" & Me.Spec & "*"""
If Nz(Me.Starting_Time, "") <> "" Then strWhere = strWhere & "([Starting Time] >= #" & Format(Me.Starting_Time, "yyyy-mm-dd") & "#) AND "
If Nz(Me.Closing_Time, "") <> "" Then strWhere = strWhere & "([Closing Time] <= #" & Format(Me.Closing_Time, "yyyy-mm-dd") & "#) AND "
If Len(strWhere) > 5 Then
Me.Showlist.RowSource = "SELECT * FROM Receiving WHERE " & strWhere
End If
End Sub
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|