使用Microsoft Access的预订系统 [英] Reservation System Using Microsoft Access
问题描述
大家好,
我想知道谁可以帮助我过滤开始日期和结束日期。我仍然无法过滤它。
例如。当用户单击StartDate(comboBox为16/7/07)时,开始日期(文本框应仅显示16/7/07),这也适用于EndDate。
Private Sub cboStartDate_Click()
''目的:从非空白搜索框中构建条件字符串,并应用于表单''的过滤器。
''注意:1。我们指的是 AND和在每个条件结束时,您可以轻松添加更多搜索框; _
我们删除尾随的" AND和最后。
''2。日期范围的工作原理如下:_
两个日期=只有日期(包括两者)。_
仅限开始日期=此日期之后的所有日期; _
结束日期=所有日期(包括此日期)。
Dim strWhere As String''标准字符串。
Dim lngLen As Long''要追加的标准字符串的长度。
Const conJetDate =" \#mm\ / dd \ / yyyy \#"''JET查询字符串中日期的格式。
''**************** ********************************* ***************** *****
''查看每个搜索框,并从非空白的搜索框中建立标准字符串。
''****** ******************************************* ******* ***************
''文本字段示例。在字符串中的值周围使用引号。
如果不是IsNull(Me.cboStartDate)那么
strWhere = strWhere&& ;(([StartDate] =''"& Me.cboStartDate& "''))或
结束如果
''************* ************************************ ************** *******
''砍掉尾随的' AND",并使用字符串作为'过滤器的形式。
''************************ ************************* ********************** >
''查看该字符串是否有超过5个字符(一个足迹AND)要删除。
lngLen = Len(strWhere) - 4
如果lngLen< = 0那么''Nah:字符串中没有任何内容。
MsgBox没有条件,vbInformation,没什么可做的。
Else''是的:那里有东西,所以删除或者或最后。
strWhere =左$(strWhere,lngLen)
''要进行调试,请删除下一行的引号。打印到立即窗口(Ctrl + G)。
Debug.Print strWhere
''最后,将字符串应用为表格''的过滤器。 br />
Me.Filter = strWhere
Me.FilterOn = True
结束如果
End Sub
私有子cboEndDate_Click()
''目的:从非空白搜索框中构建条件字符串,并应用于表单''的过滤器。
''注意:1。我们 AND和在每个条件结束时,您可以轻松添加更多搜索框; _
我们删除尾随的" AND和最后。
''2。日期范围的工作原理如下:_
两个日期=只有日期(包括两者)。_
仅限开始日期=此日期之后的所有日期; _
结束日期=所有日期(包括此日期)。
Dim strWhere As String''标准字符串。
Dim lngLen As Long''要追加的标准字符串的长度。
Const conJetDate =" \#mm\ / dd \ / yyyy \#"''JET查询字符串中日期的格式。
''**************** ********************************* ***************** *****
''查看每个搜索框,并从非空白的搜索框中建立标准字符串。
''****** ******************************************* ******* ***************
''文本字段示例。在字符串中的值周围使用引号。
如果不是IsNull(Me.cboEndDate)那么
strWhere = strWhere&&qu ot;(([EndDate] =''"& Me.cboEndDate& "''))或
结束如果
''************* ************************************ ************** *******
''砍掉尾随的' AND",并使用字符串作为'过滤器的形式。
''************************ ************************* ********************** >
''查看该字符串是否有超过5个字符(一个足迹AND)要删除。
lngLen = Len(strWhere) - 4
如果lngLen< = 0那么''Nah:字符串中没有任何内容。
MsgBox没有条件,vbInformation,没什么可做的。
Else''是的:那里有东西,所以删除 AND和最后。
strWhere =左$(strWhere,lngLen)
''要进行调试,请删除下一行的引号。打印到立即窗口(Ctrl + G)。
Debug.Print strWhere
''最后,将字符串应用为表格''的过滤器。 br />
Me.Filter = strWhere
Me.FilterOn = True
结束如果
结束Sub
Hi everyone,
I wonder who can help me on the filter the Start Date and End Date. I still cannot manage to filter it.
Eg. When the user click the StartDate(comboBox as 16/7/07), the Start Date(textbox should show only 16/7/07) and this also apply to the EndDate.
Private Sub cboStartDate_Click()
''Purpose: Build up the criteria string form the non-blank search boxes, and apply to the form''s Filter.
''Notes: 1. We tack " AND " on the end of each condition so you can easily add more search boxes; _
we remove the trailing " AND " at the end.
'' 2. The date range works like this: _
Both dates = only dates between (both inclusive. _
Start date only = all dates from this one onwards; _
End date only = all dates up to (and including this one).
Dim strWhere As String ''The criteria string.
Dim lngLen As Long ''Length of the criteria string to append to.
Const conJetDate = "\#mm\/dd\/yyyy\#" ''The format expected for dates in a JET query string.
''************************************************* **********************
''Look at each search box, and build up the criteria string from the non-blank ones.
''************************************************* **********************
''Text field example. Use quotes around the value in the string.
If Not IsNull(Me.cboStartDate) Then
strWhere = strWhere & "(([StartDate] = ''" & Me.cboStartDate & "'')) OR "
End If
''************************************************* *********************
''Chop off the trailing " AND ", and use the string as the form''s Filter.
''************************************************* **********************
''See if the string has more than 5 characters (a trailng " AND ") to remove.
lngLen = Len(strWhere) - 4
If lngLen <= 0 Then ''Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else ''Yep: there is something there, so remove the " Or " at the end.
strWhere = Left$(strWhere, lngLen)
''For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
Debug.Print strWhere
''Finally, apply the string as the form''s Filter.
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
Private Sub cboEndDate_Click()
''Purpose: Build up the criteria string form the non-blank search boxes, and apply to the form''s Filter.
''Notes: 1. We tack " AND " on the end of each condition so you can easily add more search boxes; _
we remove the trailing " AND " at the end.
'' 2. The date range works like this: _
Both dates = only dates between (both inclusive. _
Start date only = all dates from this one onwards; _
End date only = all dates up to (and including this one).
Dim strWhere As String ''The criteria string.
Dim lngLen As Long ''Length of the criteria string to append to.
Const conJetDate = "\#mm\/dd\/yyyy\#" ''The format expected for dates in a JET query string.
''************************************************* **********************
''Look at each search box, and build up the criteria string from the non-blank ones.
''************************************************* **********************
''Text field example. Use quotes around the value in the string.
If Not IsNull(Me.cboEndDate) Then
strWhere = strWhere & "(([EndDate] = ''" & Me.cboEndDate & "'')) OR "
End If
''************************************************* *********************
''Chop off the trailing " AND ", and use the string as the form''s Filter.
''************************************************* **********************
''See if the string has more than 5 characters (a trailng " AND ") to remove.
lngLen = Len(strWhere) - 4
If lngLen <= 0 Then ''Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else ''Yep: there is something there, so remove the " AND " at the end.
strWhere = Left$(strWhere, lngLen)
''For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
Debug.Print strWhere
''Finally, apply the string as the form''s Filter.
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
推荐答案
(strWhere,lngLen)
''要进行调试,请删除下一行的引号。打印到立即窗口(Ctrl + G)。
Debug.Print strWhere
''最后,将字符串应用为表格''的过滤器。 br />
Me.Filter = strWhere
Me.FilterOn = True
结束如果
End Sub
私有子cboEndDate_Click()
''目的:从非空白搜索框中构建条件字符串,并应用于表单''的过滤器。
''注意:1。我们 AND和在每个条件结束时,您可以轻松添加更多搜索框; _
我们删除尾随的" AND和最后。
''2。日期范围的工作原理如下:_
两个日期=只有日期(包括两者)。_
仅限开始日期=此日期之后的所有日期; _
结束日期=所有日期(包括此日期)。
Dim strWhere As String''标准字符串。
Dim lngLen As Long''要追加的标准字符串的长度。
Const conJetDate =" \#mm\ / dd \ / yyyy \#"''JET查询字符串中日期的格式。
''**************** ********************************* ***************** *****
''查看每个搜索框,并从非空白的搜索框中建立标准字符串。
''****** ******************************************* ******* ***************
''文本字段示例。在字符串中的值周围使用引号。
如果不是IsNull(Me.cboEndDate)那么
strWhere = strWhere&&qu ot;(([EndDate] =''"& Me.cboEndDate& "''))或
结束如果
''************* ************************************ ************** *******
''砍掉尾随的' AND",并使用字符串作为'过滤器的形式。
''************************ ************************* ********************** >
''查看该字符串是否有超过5个字符(一个足迹AND)要删除。
lngLen = Len(strWhere) - 4
如果lngLen< = 0那么''Nah:字符串中没有任何内容。
MsgBox没有条件,vbInformation,没什么可做的。
Else''是的:那里有东西,所以删除 AND和最后。
strWhere =左
(strWhere, lngLen)
''For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
Debug.Print strWhere
''Finally, apply the string as the form''s Filter.
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
Private Sub cboEndDate_Click()
''Purpose: Build up the criteria string form the non-blank search boxes, and apply to the form''s Filter.
''Notes: 1. We tack " AND " on the end of each condition so you can easily add more search boxes; _
we remove the trailing " AND " at the end.
'' 2. The date range works like this: _
Both dates = only dates between (both inclusive. _
Start date only = all dates from this one onwards; _
End date only = all dates up to (and including this one).
Dim strWhere As String ''The criteria string.
Dim lngLen As Long ''Length of the criteria string to append to.
Const conJetDate = "\#mm\/dd\/yyyy\#" ''The format expected for dates in a JET query string.
''************************************************* **********************
''Look at each search box, and build up the criteria string from the non-blank ones.
''************************************************* **********************
''Text field example. Use quotes around the value in the string.
If Not IsNull(Me.cboEndDate) Then
strWhere = strWhere & "(([EndDate] = ''" & Me.cboEndDate & "'')) OR "
End If
''************************************************* *********************
''Chop off the trailing " AND ", and use the string as the form''s Filter.
''************************************************* **********************
''See if the string has more than 5 characters (a trailng " AND ") to remove.
lngLen = Len(strWhere) - 4
If lngLen <= 0 Then ''Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else ''Yep: there is something there, so remove the " AND " at the end.
strWhere = Left
(strWhere,lngLen)
''要进行调试,请删除下一行。打印到立即窗口(Ctrl + G)。
Debug.Print strWhere
''最后,将字符串应用为表格''的过滤器。 br />
Me.Filter = strWhere
Me.FilterOn = True
结束如果
End Sub
(strWhere, lngLen)
''For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
Debug.Print strWhere
''Finally, apply the string as the form''s Filter.
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
< br>
大家好,
我想知道谁可以帮助我过滤开始日期和结束日期。我仍然无法过滤它。
例如。当用户单击StartDate(comboBox为16/7/07)时,开始日期(文本框应仅显示16/7/07),这也适用于EndDate。
Private Sub cboStartDate_Click()
''目的:从非空白搜索框中构建条件字符串,并应用于表单''的过滤器。
''注意:1。我们指的是 AND和在每个条件结束时,您可以轻松添加更多搜索框; _
我们删除尾随的" AND和最后。
''2。日期范围的工作原理如下:_
两个日期=只有日期(包括两者)。_
仅限开始日期=此日期之后的所有日期; _
结束日期=所有日期(包括此日期)。
Dim strWhere As String''标准字符串。
Dim lngLen As Long''要追加的标准字符串的长度。
Const conJetDate =" \#mm\ / dd \ / yyyy \#"''JET查询字符串中日期的格式。
''**************** ********************************* ***************** *****
''查看每个搜索框,并从非空白的搜索框中建立标准字符串。
''****** ******************************************* ******* ***************
''文本字段示例。在字符串中的值周围使用引号。
如果不是IsNull(Me.cboStartDate)那么
strWhere = strWhere&& ;(([StartDate] =''"& Me.cboStartDate& "''))或
结束如果
''************* ************************************ ************** *******
''砍掉尾随的' AND",并使用字符串作为'过滤器的形式。
''************************ ************************* ********************** >
''查看该字符串是否有超过5个字符(一个足迹AND)要删除。
lngLen = Len(strWhere) - 4
如果lngLen< = 0那么''Nah:字符串中没有任何内容。
MsgBox没有条件,vbInformation,没什么可做的。
Else''是的:那里有东西,所以删除或者或最后。
strWhere =左
Hi everyone,
I wonder who can help me on the filter the Start Date and End Date. I still cannot manage to filter it.
Eg. When the user click the StartDate(comboBox as 16/7/07), the Start Date(textbox should show only 16/7/07) and this also apply to the EndDate.
Private Sub cboStartDate_Click()
''Purpose: Build up the criteria string form the non-blank search boxes, and apply to the form''s Filter.
''Notes: 1. We tack " AND " on the end of each condition so you can easily add more search boxes; _
we remove the trailing " AND " at the end.
'' 2. The date range works like this: _
Both dates = only dates between (both inclusive. _
Start date only = all dates from this one onwards; _
End date only = all dates up to (and including this one).
Dim strWhere As String ''The criteria string.
Dim lngLen As Long ''Length of the criteria string to append to.
Const conJetDate = "\#mm\/dd\/yyyy\#" ''The format expected for dates in a JET query string.
''************************************************* **********************
''Look at each search box, and build up the criteria string from the non-blank ones.
''************************************************* **********************
''Text field example. Use quotes around the value in the string.
If Not IsNull(Me.cboStartDate) Then
strWhere = strWhere & "(([StartDate] = ''" & Me.cboStartDate & "'')) OR "
End If
''************************************************* *********************
''Chop off the trailing " AND ", and use the string as the form''s Filter.
''************************************************* **********************
''See if the string has more than 5 characters (a trailng " AND ") to remove.
lngLen = Len(strWhere) - 4
If lngLen <= 0 Then ''Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else ''Yep: there is something there, so remove the " Or " at the end.
strWhere = Left
这篇关于使用Microsoft Access的预订系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!