473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

prevent bookin while the car is on hire

hey,
i am building a system for car hiring company. the tables are as follows

tbl: client details
tbl: Car Details
tbl: Hire

hire table contains the following fields
Client ID
Car ID
Hire ID
Start Date
End Date

i want to know when creating the form how do i build the beforeupdate expression so when i try booking a car that is ALREADY on hire for a client, is not rebooked untill the car is returned.
Mar 3 '10 #1
3 1422
beacon
579 512MB
Is the return of the car indicated by the End Date field? If so, you could use DLookup to see if the field is null or not and throw an error message if it is. I'm not sure I would use BeforeUpdate though, but that's mostly just personal preference. Also, I would remove the spaces in your field names...for instance, I would change End Date to EndDate.

Here's an example of DLookup:
Expand|Select|Wrap|Line Numbers
  1. Dim varHire As Variant     'declare a variable for the hire ID. I used variant because I'm not sure what data type HireID is.
  2. Dim strHire As Variant     'declare a variable for the return value of DLookup
  3.  
  4. varHire = txtHire     'this assumes that you get the hire ID from a field on a form
  5.  
  6. strHire = DLookup("EndDate", "tblHire", "HireID = '" & varHire & "'")   'EndDate is the field you're looking up, tblHire is the table you look in, and HireID is the lookup value to compare against.
  7.  
  8. if Not IsNull(strHire) then
  9.      MsgBox "The vehicle you are trying to book has already been allocated", vbExclamation, "Error - Booked Vehicle"     'inform the user that the vehicle has already been booked
  10.      Me.HireID = Null     'set the hire field to null
  11.      Me.HireID.SetFocus     'put the cursor back in the hire field so the user can select another vehicle
  12.      Exit Sub     'exit the sub so that the user can re-enter an hire ID
  13. end if
  14.  
Mar 3 '10 #2
hey thanks for the reply, i tried using the above but it still dont work.. is it possible i can do it as a query?
Mar 4 '10 #3
NeoPa
32,556 Expert Mod 16PB
If you post the SQL you're currently using for your form we can tell you how to amend it to filter out those items currently on hire.
Mar 4 '10 #4

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

Similar topics

2
by: Richard Tarjeft | last post by:
I need to hire a python programmer for a small modification project. Where is the best place to find one? Richard Tarjeft http://www.mlmlead.net http://www.lowcostlocal.com...
3
by: Tony Maresca | last post by:
Hi. I have a class derived from a UserControl, that I want to allow others to derive controls from. I don't want them to design the base class (which is derived from a UserControl). I know that...
2
by: techfuzz | last post by:
I scoured this group and others looking for the best way to disable a button after the first click to prevent multiple submissions, but never did find anything that worked like they said it would. ...
13
by: ts-dev | last post by:
Is it possible to prevent modification of a python file once its been deployed? File permissions of the OS could be used..but that doesn't seem very secure. The root of my question is verifying...
0
by: kumar | last post by:
Hi if you are intrested in this position pls send me your updated resume asap. Location:King of Prussia, P.A Duration:9 months+hire Responsible for mid-tier server development to interface...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
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,...

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.