473,757 Members | 8,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reservation System Using Microsoft Access

14 New Member
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(combo Box as 16/7/07), the Start Date(textbox should show only 16/7/07) and this also apply to the EndDate.

Private Sub cboStartDate_Cl ick()

'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.cboSt artDate) 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_Clic k()

'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.cboEn dDate) 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
Jun 14 '07 #1
23 7134
nairda
39 New Member
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(combo Box as 16/7/07), the Start Date(textbox should show only 16/7/07) and this also apply to the EndDate.

Private Sub cboStartDate_Cl ick()

'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.cboSt artDate) 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_Clic k()

'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.cboEn dDate) 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

Hi, Steven

I'm not sure about what you want to make here, but I think you want to filter datas in your database using START DATE criteria nad END DATE criteria.
If this's right, I hope these codes can give you a hint about how to filter your data based on a period of time:

1. Instead of using comboboxes as your criteria input, it's easier to use DateTime Picker. (Project > Components > Microsoft Windows Common Control-2 6)

2. Use DT Picker to replace your combobox.

3. Use this SQL code:
Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM GUESTLIST WHERE Date>=#" & DTPicker1.Value & "# AND Date<=#" & DTPicker2.Value & "#"
4.You can change >= to just > and <= to < if you do not want to include the dates

FYI, I have a quite same problem a few days ago and have been solved by the forum. You can check the tread with header: "show report sort by period of time" on this forum.

Nairda
Jun 14 '07 #2
Steven TK
14 New Member
Hi, Steven

I'm not sure about what you want to make here, but I think you want to filter datas in your database using START DATE criteria nad END DATE criteria.
If this's right, I hope these codes can give you a hint about how to filter your data based on a period of time:

1. Instead of using comboboxes as your criteria input, it's easier to use DateTime Picker. (Project > Components > Microsoft Windows Common Control-2 6)

2. Use DT Picker to replace your combobox.

3. Use this SQL code:
Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM GUESTLIST WHERE Date>=#" & DTPicker1.Value & "# AND Date<=#" & DTPicker2.Value & "#"
4.You can change >= to just > and <= to < if you do not want to include the dates

FYI, I have a quite same problem a few days ago and have been solved by the forum. You can check the tread with header: "show report sort by period of time" on this forum.

Nairda
Hi Nairda,

Where do you get the Date Time Picker Control in microsoft access
Jun 14 '07 #3
nairda
39 New Member
Hi Nairda,

Where do you get the Date Time Picker Control in microsoft access
Hi,
Not in Ms.Access. Date Time Picker is a VB Component.
You can find it in Menu Project > Components > give a check sign on Microsoft Windows Common Controls-2.6.0. And then you can put DT Picker from your toolbox to your VB form.
You can use it to subtitute your combobox if you wanted to make a date list.
Give it a try.

Nairda
Jun 14 '07 #4
Steven TK
14 New Member
Hi,
Not in Ms.Access. Date Time Picker is a VB Component.
You can find it in Menu Project > Components > give a check sign on Microsoft Windows Common Controls-2.6.0. And then you can put DT Picker from your toolbox to your VB form.
You can use it to subtitute your combobox if you wanted to make a date list.
Give it a try.

Nairda
Hi Nairda, i try go to the component in the microsoft visual basic. I find only the microsoft window common control version 6 (SP 6) but i can't get the date picker as u say after i check the microsoft window common control version 6 (SP 6).
Jun 14 '07 #5
nairda
39 New Member
Hi Nairda, i try go to the component in the microsoft visual basic. I find only the microsoft window common control version 6 (SP 6) but i can't get the date picker as u say after i check the microsoft window common control version 6 (SP 6).

That's right, you can't find DT Picker if you selected Windows Common Control 6. You have to choose Windows Common Control 2.6.0 (SP4). I think the problem is we have a different version of VB or its Service Pack.
FYI, I used Visual Basic 6.0

In case you can't find DT Picker, you can still use your comboboxes, asl long as you use the same date format between your combo boxes and your database.
So if you use "mm dd yyyy" date format in your database, you have to add the same data format in your combo boxes.
The SQL code is the same (You just need to change DTPicker1.value with combo1.text)
The difference is you have to input many date in your combobox list meanwhile DT Picker has already give a "calendar looks" for you. You just pick the date you wanted.

Nairda
Jun 14 '07 #6
Steven TK
14 New Member
That's right, you can't find DT Picker if you selected Windows Common Control 6. You have to choose Windows Common Control 2.6.0 (SP4). I think the problem is we have a different version of VB or its Service Pack.
FYI, I used Visual Basic 6.0

In case you can't find DT Picker, you can still use your comboboxes, asl long as you use the same date format between your combo boxes and your database.
So if you use "mm dd yyyy" date format in your database, you have to add the same data format in your combo boxes.
The SQL code is the same (You just need to change DTPicker1.value with combo1.text)
The difference is you have to input many date in your combobox list meanwhile DT Picker has already give a "calendar looks" for you. You just pick the date you wanted.

Nairda
Hi Nairda,

I have a calendar control, 2 comboBox Date (1 is for the Start date and the other one is the End date). I want the user to choose according to their start date and end date by click the date they want in the calendar. Then the textbox will filter the date according to their needs
Jun 14 '07 #7
nairda
39 New Member
Hi Nairda,

I have a calendar control, 2 comboBox Date (1 is for the Start date and the other one is the End date). I want the user to choose according to their start date and end date by click the date they want in the calendar. Then the textbox will filter the date according to their needs

OK, I think you can do as I write before. Just be careful with your date format.

Nairda
Jun 14 '07 #8
hariharanmca
1,977 Top Contributor
Hi Nairda,

I have a calendar control, 2 comboBox Date (1 is for the Start date and the other one is the End date). I want the user to choose according to their start date and end date by click the date they want in the calendar. Then the textbox will filter the date according to their needs

This is for MS Access :

Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM GUESTLIST WHERE Date>=#" & Format(DTPicker1.Value,"MM/dd/yyyy") & "# AND Date<=#" & Format(DTPicker1.Value,"MM/dd/yyyy")  & "#"
This is for SQL Server :

Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM GUESTLIST WHERE Date>= ' " & Format(DTPicker1.Value,"MM/dd/yyyy") & " ' AND Date<= ' " & Format(DTPicker1.Value,"MM/dd/yyyy")  & " ' "
Make sure that both date format should be Month/Day/Year format

other wise it will select the corresponding date format date only
Jun 14 '07 #9
Steven TK
14 New Member
This is for MS Access :

Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM GUESTLIST WHERE Date>=#" & Format(DTPicker1.Value,"MM/dd/yyyy") & "# AND Date<=#" & Format(DTPicker1.Value,"MM/dd/yyyy")  & "#"
This is for SQL Server :

Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM GUESTLIST WHERE Date>= ' " & Format(DTPicker1.Value,"MM/dd/yyyy") & " ' AND Date<= ' " & Format(DTPicker1.Value,"MM/dd/yyyy")  & " ' "
Make sure that both date format should be Month/Day/Year format

other wise it will select the corresponding date format date only
Sorry Nairda,

I wonder where you put this code in??

I am newbie for MS Access.. Maybe u tell me the procedure that could be better.. Sorry to trouble u.
Jun 14 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2131
by: John Bevilaqua | last post by:
We have developed a prototype working application to handle Reservations or Appointments into an Access 2002 or SQL Server 2000 backend system. These Reservations can be originated using an Interactive Voice Response System (IVR), a Web enabled form, and in the 4th Quarter of 2003, a Palm Pilot interface, too. They all feed into the same backend database in real-time offering considerable savings in determining the exact
11
5229
by: Robert | last post by:
Would you use Access to create a car rental reservation system? I would think that the complexity of such a system would be better suited to a procedural language like Visual Basic or C++. Your thoughts, please. Robert
5
4809
by: KarlM | last post by:
Is there any sample code for making a DHCP reservation via C#? Thanks in advance
4
6087
by: johnny.shz | last post by:
Hi, does anyone know a php5 based web calendar and reservation system? I'm looking for the following features: 1. two types of users: a calendar owner, and guests 2. guests can see what slots are free or reserved, can make a reservation, cancel a reservation 3. owner can confirm a reservation Thanks.
1
4883
by: hiboo | last post by:
Does anyone know of any open source java software/code libraries for doing travel/airline reservations? I'm looking for a typical airline (hotel, car rental?) reservation system. system in perl or c, c++ ok.
1
3419
by: tabloidster | last post by:
Howdy All, I recall seeing a similar post a while back, but I'm not an expert VB programmer so I'm still not clear... For my VB6 class, I've got to code a basic reservation system. Let's say that the plane has 6 passenger seats total via 2 columns (A and B for arguements sake) and 3 rows per column. An array here, right? We have to display a seating chart, which I could probably setup with labels and set the caption property with green...
11
5200
by: jimmy | last post by:
I'm in the process of developing a reservation management system for small restaurants. I am stuck on creating an algorigthm for managing the reservations. For example i need to check that a table is avaialbe and when etc. I understand that i'll need a database table containing information about the tables in the restaurant but further than this im pretty clueless so any help would be much appreciated.
0
2791
by: =?iso-8859-1?Q?Leentje=AE?= | last post by:
Hi, i'm surching a een asp-script "room reservation" i've searched with google, without succes the good scripts are to be payed but i'm looking for a free script example: the room-reservation-system from digirez http://www.digiappz.com/digirez.asp?id=1 is magnificent (demo : http://www.digiappz.com/room/index.asp )
2
7572
by: cotty | last post by:
AIRLINE RESERVATION SYSTEM A small airline has just purchased a computer for its new automated reservations system. The president has asked you to program the new system in C. You are to write a program to assign seats on each flight of the airline’s only plane (capacity: 20 seats). Your program should display the following menu alternatives: Please type 1 for “business” Please type 2 for “economy” If the person types 1, then your...
0
2259
by: jrhitokiri | last post by:
QUESTION 1: I'm trying to create a room reservation system for school using wicket and MySQL, and I'm a bit confused with this one. I've already created the user database and rooms database. My question is how do I create a schema that accepts both repeating and non-repeating schedules? example (repeating): I can reserve a room for class at 9:00am - 12:00pm every Monday and Thursday, from June - October of 2009. How do I represent this in...
0
9298
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.