Any ideas on how to write a query which verifies availability for an equipment by checking on the date, time and item, to make sure it's not already being used ?:confused:
Printable View
Any ideas on how to write a query which verifies availability for an equipment by checking on the date, time and item, to make sure it's not already being used ?:confused:
How are you going to compare them? by user input or something else?
if user input then
let's say you have 3 textboxes date, time and item
the you could do this to search for a specific item
SELECT * FROM tablename WHERE date <> '" & txtDate.Text & "' AND time <> '" & txtTime.Text & "' AND item = '" & txtItem.Text & "'"
The date will be in an interval (startdate to enddate) specified on two comboboxes, so will be the time.
if you want to search between 2 dates and 2 times then it would be
The syntax maybe a little different depending on the database you are using.Code:SELECT * FROM tablename WHERE date BETWEEN '" & txtDate1.Text & "' AND '" & txtDate2.Text & "' AND time BETWEEN '" & txtTime1.Text & "' AND '" & txtTime2.Text & "' AND item = '" & txtItem.Text & "'"
Thanks, but how do you compare the time? Do you have to assign a specific data type to this variable or control so that you can compare what's in the recordset with the users' input?
yes, make sure the datatype of the varaible holding the users input is the same as that in the database.