473,657 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check for Duplicate Appointment Times

I have a simple application that takes user input by text and time
selected by date time picker. It displays the appt description in one
list box and the time in another list box. I need a simple function
that checks the times for duplicates. I want to check for a duplicate
before it writes to the listbox by returning a boolean (true/false)
value. I only need to check hours and minutes not date or seconds. I'm
new to this so any help would be appreciated.

Thanks

Nov 14 '06 #1
3 1322
Hello,

I am going to assume a Windows form.

You basically have to loop through the listbox. Examine each entry by setting it's selected value to true. Read the value of the selected row and then validate it.

Sample:
Dim i As Integer
Dim bolAddNew as Boolean

For i = 0 To Me.ListBox1.Ite ms.Count
Me.ListBox1.Sel ectedIndex = i
If Me.ListBox1.Sel ectedValue = txtTime.Text Then
bolAddNew = True
Exit For
Else
BolAddNew = False
End If
Next

If boilAddNew Then
'Add New Time
Else
'Optional: Display MSGBOX
End If

"geo039" <ca************ @hotmail.comwro te in message news:11******** *************@f 16g2000cwb.goog legroups.com...
>I have a simple application that takes user input by text and time
selected by date time picker. It displays the appt description in one
list box and the time in another list box. I need a simple function
that checks the times for duplicates. I want to check for a duplicate
before it writes to the listbox by returning a boolean (true/false)
value. I only need to check hours and minutes not date or seconds. I'm
new to this so any help would be appreciated.

Thanks
Nov 14 '06 #2
Right now I have this but it's not finding duplicates, I think there's
a problem with the function? Any Suggestions?

Dim Time As Boolean

Time = TimeTaken(Me.dt mTime.Value.ToS hortDateString)

If Time Then
MessageBox.Show ("You already have an appointment at
this time")
Else

'display appointment in Listbox
lstApptResults. Items.Add(txtAp pointment.Text)
txtAppointment. Clear() 'clear appointment from TextBox
txtAppointment. Focus() 'transfer focus to TextBox

'display appointment time in Listbox

lstTimeResults. Items.Add(Me.dt mTime.Value.ToS hortTimeString)

End If
End If
End Sub 'btnAddAppt_Cli ck
'function to check if an appointment time already exists in listbox
Public Function TimeTaken(ByVal ApptTime As DateTime) As Boolean

Dim DuplicateTime As Boolean = False

'loop that checks listed times for duplicates
For Each strItem As String In lstTimeResults. Items
If strItem = ApptTime Then
DuplicateTime = True

Exit For
End If
Next

Return DuplicateTime
End Function 'TimeTaken

Nov 14 '06 #3
If you step through the program, what value are you passing to TimeTaken?
It looks as though you are passing a date and not time.

"geo039" <ca************ @hotmail.comwro te in message
news:11******** *************@m 73g2000cwd.goog legroups.com...
Right now I have this but it's not finding duplicates, I think there's
a problem with the function? Any Suggestions?

Dim Time As Boolean

Time = TimeTaken(Me.dt mTime.Value.ToS hortDateString)

If Time Then
MessageBox.Show ("You already have an appointment at
this time")
Else

'display appointment in Listbox
lstApptResults. Items.Add(txtAp pointment.Text)
txtAppointment. Clear() 'clear appointment from TextBox
txtAppointment. Focus() 'transfer focus to TextBox

'display appointment time in Listbox

lstTimeResults. Items.Add(Me.dt mTime.Value.ToS hortTimeString)

End If
End If
End Sub 'btnAddAppt_Cli ck
'function to check if an appointment time already exists in listbox
Public Function TimeTaken(ByVal ApptTime As DateTime) As Boolean

Dim DuplicateTime As Boolean = False

'loop that checks listed times for duplicates
For Each strItem As String In lstTimeResults. Items
If strItem = ApptTime Then
DuplicateTime = True

Exit For
End If
Next

Return DuplicateTime
End Function 'TimeTaken

Nov 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7511
by: Sam | last post by:
My db looks after the hiring and lending of equipment, the form which books out equipment hired prints a signout sheet and automatically inserts an appointment into outlook advising the operator on the due date that a particular hire is due. I have used microsoft's automated appointment code to do this, what I would also like the code to do is to email an appointment to the person hiring the gear. Knowing that you can email an...
5
2319
by: Notgiven | last post by:
You want to check scheduling conflicts and you have a record like: appointments(table): apptID beginningDate endingDate beginningTime endingTime It's easy enough to check if a time is within that record. Say you want to
1
1355
by: Colin Possamai | last post by:
I have a table with 14 days and appointment times. The days are numbered 0 to 13 (fortnight worth). I have a query (FortnightQuotesAppointments) that adds now() to day number to get the date of the next 14 days. I have a table/form with a combo box with the list of dates and times for the next fortnight for a quote appointment from this query (FortnightQuotesAppointments). I want to be able to delete the unavailable appointments from the...
13
9956
by: YoVoltron | last post by:
I am just starting this "appointment book" java program and would appreciate some basis direction. I do not expect anyone to write the code for me but i would like opinions on how to best handle the situation. Specifically should i use <arraylist> or a hashtable or is these a better way? Thank you all in advance. here is the assignment... sorry if it is too long. In this assignment you will demonstrate your understanding of designing with...
7
1627
by: geo039 | last post by:
I have a simple application that takes user input by text and time selected by date time picker. It displays the appt description in one list box and the time in another list box. I need a simple function that checks the times for duplicates. I want to check for a duplicate before it writes to the listbox by returning a boolean (true/false) value I'm new to this so any help would be appreciated. Thanks
2
1143
by: zabartcc | last post by:
Hey guys. I’m having a problem and I need help desperately. I am writing an appointment scheduler and have run into an issue. I have an access database to store all the appointment information. Now here is the catch, I can’t have any overlapping appointments. I can’t figure out how to determine if there is something already scheduled at that time because in the database it stores it like 08:00 AM to 10:00 AM. Any help would be greatly...
4
2140
geo039
by: geo039 | last post by:
I tried to write a simple application that takes user input by text and time selected by date time picker. It displays the appt description in one list box and the time in another list box. I wrote a simple function that checks the times for duplicates. I wanted to check for a duplicate before it writes to the listbox by returning a boolean (true/false) value. I only need to check hours and minutes not date or seconds. The following is...
2
3662
by: Kosmos | last post by:
Alright so I've got this Outlook code written in VBA in Access. The first part, which works, records information about appointment times based on the required days before notification of certain contracts and then it adds them to the outlook calendar of the current user. This code works and is nested within a bunch of if statements because it only needs to trap certain appointments. The table I create with this code is later used to attempt to...
2
2541
by: Ranma13 | last post by:
Hello, I have a duplicate record check written in VB for a check in/check out database. Here's the pseudocode, written for the BeforeUpdate property on the form: If DCount(search for records with the same TimeIn and TimeOut) > 0 Then MsgBox("Duplicate record found") Undo and set focus End Sub This code works fine if you try to add a new record that has duplicate times for TimeIn and TimeOut, but when I try to modify an...
0
8324
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
8740
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
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
7352
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...
0
5642
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
4173
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...
1
2742
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
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
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.