473,769 Members | 8,267 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
23 7135
Steven TK
14 New Member
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.
Thank Nairda,

I know how do it already.
Jun 15 '07 #11
nairda
39 New Member
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.

Not at all, Steve. This what the forum is for.
Ok, I'll give you a picture:

I have a hotel reservation Ms. Access table (RESERV.mdb). It contains some columns (CHECKINDATE, CHECKOUTDATE, ROOM_NO, GUESTNAME, etc).
And then I have this report form which I use for setting some criterias to show the report. In this case I want to show list of all guest stayed in my hotel between CHECKINDATE in combo1 and CHECKOUTDATE combo2.
So, I have two combo boxes. Combo1 is to set the beginning of the report (CHECKINDATE) i wanted to show, combo2 is for the ending of the report (CHECHOUTDATE) I wanted to show.
Beside those two combos, I also made a commandbutton (cmdshow) as a trigger for the action and a mshflexgrid to show the data. So, I put the code in cmdshow.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdshow_Click()
  2.     Dim conec As New ADODB.Connection
  3.     Dim rs As New ADODB.Recordset
  4.     conec.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source ='" & App.Path & "\DATABASE.mdb'"
  5.     conec.CursorLocation = adUseClient
  6.     conec.Open
  7.  
  8.     If (Combo1.Text = "") and (Combo2.Text = "") Then
  9.         MsgBox "Please fill the criteria", vbExclamation
  10.         Combo1.SetFocus
  11.         Else
  12.             rs.CursorLocation = adUseClient
  13.             rs.Open "SELECT * FROM RESERV WHERE CHECKINDATE>=#" & CDate(Combo1.Text) & "# AND CHECKOUTDATE<=#" & CDate(Combo2.Text) & "# '", conec, adOpenDynamic, adLockOptimistic
  14.             Set MSHFlexGrid1.DataSource = rs
  15.     End If
  16.     rs.Close
  17. End Sub
It's better if you could find the DT Picker. If you could, the code above will be:
Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM RESERV WHERE CHECKINDATE>=#" & DTPicker1.Value & "# AND CHECKOUTDATE<=#" & DTPicker2.Value & "# ", conec, adOpenDynamic, adLockOptimistic
You can do a right click on DTPicker to show its properties and change the dateformat to suit your database's dateformat

OR you can use the code sent by hariharanmca (thank you):

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")  & " ' "
To hariharanmca: How to show DT Picker when you don't have "Microsoft Windows Common Control 2.6.0" in your Project Components? Steve don't have it. I have no idea about this, because I've already had it when I installed my VB6.

Thank you n Good luck!

Nairda
Jun 15 '07 #12
Steven TK
14 New Member
Not at all, Steve. This what the forum is for.
Ok, I'll give you a picture:

I have a hotel reservation Ms. Access table (RESERV.mdb). It contains some columns (CHECKINDATE, CHECKOUTDATE, ROOM_NO, GUESTNAME, etc).
And then I have this report form which I use for setting some criterias to show the report. In this case I want to show list of all guest stayed in my hotel between CHECKINDATE in combo1 and CHECKOUTDATE combo2.
So, I have two combo boxes. Combo1 is to set the beginning of the report (CHECKINDATE) i wanted to show, combo2 is for the ending of the report (CHECHOUTDATE) I wanted to show.
Beside those two combos, I also made a commandbutton (cmdshow) as a trigger for the action and a mshflexgrid to show the data. So, I put the code in cmdshow.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdshow_Click()
  2.     Dim conec As New ADODB.Connection
  3.     Dim rs As New ADODB.Recordset
  4.     conec.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source ='" & App.Path & "\DATABASE.mdb'"
  5.     conec.CursorLocation = adUseClient
  6.     conec.Open
  7.  
  8.     If (Combo1.Text = "") and (Combo2.Text = "") Then
  9.         MsgBox "Please fill the criteria", vbExclamation
  10.         Combo1.SetFocus
  11.         Else
  12.             rs.CursorLocation = adUseClient
  13.             rs.Open "SELECT * FROM RESERV WHERE CHECKINDATE>=#" & CDate(Combo1.Text) & "# AND CHECKOUTDATE<=#" & CDate(Combo2.Text) & "# '", conec, adOpenDynamic, adLockOptimistic
  14.             Set MSHFlexGrid1.DataSource = rs
  15.     End If
  16.     rs.Close
  17. End Sub
It's better if you could find the DT Picker. If you could, the code above will be:
Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM RESERV WHERE CHECKINDATE>=#" & DTPicker1.Value & "# AND CHECKOUTDATE<=#" & DTPicker2.Value & "# ", conec, adOpenDynamic, adLockOptimistic
You can do a right click on DTPicker to show its properties and change the dateformat to suit your database's dateformat

OR you can use the code sent by hariharanmca (thank you):

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")  & " ' "
To hariharanmca: How to show DT Picker when you don't have "Microsoft Windows Common Control 2.6.0" in your Project Components? Steve don't have it. I have no idea about this, because I've already had it when I installed my VB6.

Thank you n Good luck!

Nairda
Hi Nairda, I got a question to ask you. Do you this error??

The table ‘ReservationTab le’ is already opened exclusively by another user, or it is already open through the user interface and cannot be manipulated programmaticall y.
Jun 15 '07 #13
Steven TK
14 New Member
Not at all, Steve. This what the forum is for.
Ok, I'll give you a picture:

I have a hotel reservation Ms. Access table (RESERV.mdb). It contains some columns (CHECKINDATE, CHECKOUTDATE, ROOM_NO, GUESTNAME, etc).
And then I have this report form which I use for setting some criterias to show the report. In this case I want to show list of all guest stayed in my hotel between CHECKINDATE in combo1 and CHECKOUTDATE combo2.
So, I have two combo boxes. Combo1 is to set the beginning of the report (CHECKINDATE) i wanted to show, combo2 is for the ending of the report (CHECHOUTDATE) I wanted to show.
Beside those two combos, I also made a commandbutton (cmdshow) as a trigger for the action and a mshflexgrid to show the data. So, I put the code in cmdshow.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdshow_Click()
  2.     Dim conec As New ADODB.Connection
  3.     Dim rs As New ADODB.Recordset
  4.     conec.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source ='" & App.Path & "\DATABASE.mdb'"
  5.     conec.CursorLocation = adUseClient
  6.     conec.Open
  7.  
  8.     If (Combo1.Text = "") and (Combo2.Text = "") Then
  9.         MsgBox "Please fill the criteria", vbExclamation
  10.         Combo1.SetFocus
  11.         Else
  12.             rs.CursorLocation = adUseClient
  13.             rs.Open "SELECT * FROM RESERV WHERE CHECKINDATE>=#" & CDate(Combo1.Text) & "# AND CHECKOUTDATE<=#" & CDate(Combo2.Text) & "# '", conec, adOpenDynamic, adLockOptimistic
  14.             Set MSHFlexGrid1.DataSource = rs
  15.     End If
  16.     rs.Close
  17. End Sub
It's better if you could find the DT Picker. If you could, the code above will be:
Expand|Select|Wrap|Line Numbers
  1. "SELECT * FROM RESERV WHERE CHECKINDATE>=#" & DTPicker1.Value & "# AND CHECKOUTDATE<=#" & DTPicker2.Value & "# ", conec, adOpenDynamic, adLockOptimistic
You can do a right click on DTPicker to show its properties and change the dateformat to suit your database's dateformat

OR you can use the code sent by hariharanmca (thank you):

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")  & " ' "
To hariharanmca: How to show DT Picker when you don't have "Microsoft Windows Common Control 2.6.0" in your Project Components? Steve don't have it. I have no idea about this, because I've already had it when I installed my VB6.

Thank you n Good luck!

Nairda
Hi Nairda, I got a question to ask you. Do you this error??

The table ‘ReservationTab le’ is already opened exclusively by another user, or it is already open through the user interface and cannot be manipulated programmaticall y. When i press the reserve button, it should go to the reservation form but it show me this error
Jun 15 '07 #14
nairda
39 New Member
Hi Nairda, I got a question to ask you. Do you this error??

The table ‘ReservationTab le’ is already opened exclusively by another user, or it is already open through the user interface and cannot be manipulated programmaticall y. When i press the reserve button, it should go to the reservation form but it show me this error

Hold on, I got confused here.
What's your programs's story exactly? You want to show a report from your guestdatabase OR you want to make a reservation form to fill by guests?

Nairda
Jun 15 '07 #15
Steven TK
14 New Member
Hold on, I got confused here.
What's your programs's story exactly? You want to show a report from your guestdatabase OR you want to make a reservation form to fill by guests?

Nairda
Nairda,
I want to make a reservation form to fill by guests and i have a search engine form . The user just go to the search engine then after looking the tool they want then they click the reserve button in search engine form to reserve the tool they want
Jun 15 '07 #16
nairda
39 New Member
Nairda,
I want to make a reservation form to fill by guests and i have a search engine form . The user just go to the search engine then after looking the tool they want then they click the reserve button in search engine form to reserve the tool they want

Geez, We've headed to a wrong way then. Sorry.
If it's an input form, why bother filtering your startdate and enddate? Just give the guests some comboboxes to fill the date and month they wanted, and then save it to your reservation database after they clicked a command button.

Nairda
Jun 15 '07 #17
Steven TK
14 New Member
Geez, We've headed to a wrong way then. Sorry.
If it's an input form, why bother filtering your startdate and enddate? Just give the guests some comboboxes to fill the date and month they wanted, and then save it to your reservation database after they clicked a command button.

Nairda
Hi Nairda,

Do you know how to filter the date in between the date range?

Eg. Start Date = 7/20/2007 and End Date = 7/22/2007

Then the user select Start Date = 7/20/2007 and End Date = 7/21/2007 , it can show this date Start Date = 7/20/2007 and End Date = 7/22/2007 also.
Jun 15 '07 #18
nairda
39 New Member
Hi Nairda,

Do you know how to filter the date in between the date range?

Eg. Start Date = 7/20/2007 and End Date = 7/22/2007

Then the user select Start Date = 7/20/2007 and End Date = 7/21/2007 , it can show this date Start Date = 7/20/2007 and End Date = 7/22/2007 also.

Hi,
I think You can't do that. Because no matter how your database date length, the user only selected date 20 and 21.
Assume that today's date is 7/21/2007.
If user picked 2 dates (1= 7?20/2007, 2= 7/21/2007), You can only show date 20 and 21. Because the 22 is not yet happened.
The point is, if you have a criteria to filter your data, you can't show others datas outside the criteria.

To filter the date between, you can still use the codes I wrote before.

Nairda
Jun 15 '07 #19
Steven TK
14 New Member
Hi,
I think You can't do that. Because no matter how your database date length, the user only selected date 20 and 21.
Assume that today's date is 7/21/2007.
If user picked 2 dates (1= 7?20/2007, 2= 7/21/2007), You can only show date 20 and 21. Because the 22 is not yet happened.
The point is, if you have a criteria to filter your data, you can't show others datas outside the criteria.

To filter the date between, you can still use the codes I wrote before.

Nairda
Hi Nairda, I figure the previous problem. Thank anyway.

Do you know how to close the table by writing codes?

By the way, I am wondering how to show in the calendar that can classified which equipment is book or not?
Jun 20 '07 #20

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
5230
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
3420
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
2261
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
10216
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
9997
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
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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
6675
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();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
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
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.