MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old June 17th, 2004, 06:05 AM
SUPRA80 SUPRA80 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 SUPRA80 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Sql Problem

Hi

I have created an appointment booker GUI in VB that uses a msaccess db as a backend.

I have an appointment table that consists of multiple fields, the main ones are a [STARTDAY],[ENDDAY],[STARTTIME],[ENDTIME] my problem is what i would like to do is if an employee enters and appointment but already has that time duration filled by another appointment I would like to notify the user telling them they cannot use this time frame because they have an existing appointment already, I have done the coding and thought that I had figured out the SQL Statement for this however sometimes it works and sometimes it does not. Please Help, or if anyone has any other ideas of how i can do this your help would be greatly appreciated.

The tempremental query that I have written is
SELECT EMPID,STARTDAY,STARTTIME,ENDTIME" & _
" From TAppointment" & _
" WHERE STARTTIME=(SELECT Max(MaxAppt.STARTTIME) AS MaxStartTime" & _
" FROM TAppointment As MaxAppt WHERE StartTime <= #" & endtime & "#) AND EMPID = '" & empid & "' AND STARTDAY = #" & startday & "# "

Reply With Quote
  #2  
Old June 17th, 2004, 12:05 PM
jstrohofer jstrohofer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Cincinnati, OH USA
Posts: 111 jstrohofer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 3 sec
Reputation Power: 5
Wouldn't you want to pass in the actual starting TIME of the appointment they want to make, and then check to make sure that start TIME isn't between any start and end times for that user for that day?

It may be something like:

"SELECT EMPID, STARTDAY, STARTTIME, ENDTIME " & _
"FROM TAppointment " & _
"WHERE #" & newApptStartTime & "# BETWEEN " & _
"STARTTIME AND ENDTIME " & _
"AND EMPID = '" & empid & "' AND " & _
"STARTDAY = #" & startday & "# "

Then if it returns no results, they can add the time.

Again, I'm not sure if Access supports the BETWEEN syntax.

Hope that helps,

Jill

Reply With Quote
  #3  
Old June 18th, 2004, 12:10 AM
I_LOVE_MAFFLE I_LOVE_MAFFLE is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 2 I_LOVE_MAFFLE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Suggestion: You could use a Function/Trigger/Stored Proc for this one.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Sql Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway