If Me.開始日期 > Me.截止日期 Then
MsgBox "您選擇的開始日期晚於截止日期!", vbExclamation, "錯誤"
Else
Dim strWhere As String
strWhere = True
If Not IsNull(Me.開始日期) Then
If Not IsNull(Me.截止日期) Then
strWhere = strWhere & " and [車輛注冊日期] between #" & Me!開始日期 & "# and #" & Me.截止日期 & "#"
Else
strWhere = strWhere & " and [車輛注冊日期] >= #" & Me.開始日期 & "#"
End If
Else
If Not IsNull(Me.截止日期) Then
strWhere = strWhere & " and [車輛注冊日期] <= #" & Me.截止日期 & "#"
End If
End If
If Not IsNull(Me.車號) Then
strWhere = strWhere & " and [車號] Like '*" & Me.車號 & "*'"
End If
If Not IsNull(Me.車型) Then
strWhere = strWhere & " and [車型] = '" & Me.車型 & "'"
End If
With Forms!主控面板!Child0.Form!車輛信息_child.Form
.Filter = strWhere
.FilterOn = True
End With
DoCmd.Close acForm, Me.Name, acSaveNo