Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 7th, 2005, 03:03 PM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need Help Programming a Date Comparison Database

I am working on a database project that needs to utilize date comparison code. I could really use some help on this one. Heres the problem below..



Problem:



I need to construct code that compares data in three fields: Assets, StartDate, and EndDate. I have a database that I want to be able to schedule the use of assets for customers from a start date to and end date. Once an asset is scheduled for a customer from the start date, it cannot be used for another customer until after the end date. If an asset is already scheduled, then an error message box will appear on my form, or if the end date is before the start date an error message box will appear.(Sort of like Library Book code that allows the check out and return date of a book where no one else can check the book out until it is returned by the customer) If there is anyone out there who knows of code that I can use to program a form button on my Access 2003 database project please help. I have tried to write it out below in this form:


On Click
1. Opens qryScheduledResourceType
2. Compares Resource Type with StartDate and EndDate.
3. If there is no conflict with the Resource Type and dates, Then a new record
                Will be saved.
4. If not, an error message will occur because either resources are already scheduled with the new dates or the end date preceeds the startdate.



I have started to try to write code for this, however I know that I am missing quite a few pieces:

Private Sub CommandSave_Click()
DoCmd.OpenQuery qryScheduleResourceType, acPreview

If ResourceType = 0 Then
Perform Save Function
ElseIf ResourceType > 0, Where StartDate (New) = between StartDate (Old) and EndDate (Old)Then
MsgBox "Scheduling Error-Resource Type Already Scheduled. Pick Another Resource Type or other Dates"
ElseIf EndDate < StartDate Then
MsgBox "End Date Error - End Date Occurs Before Start Date"
End If
End Function



I know this is crude, but it is the only way that I can come up with to explain this. I wish to tie this code, if possible to a Save record button on my form that will run this test, and either input the new record, or will produce an error message telling the customer to reschedule either another asset or dates. If you know how I can do this, I would really appreciate the help. I can be reached by reply to this email or the mail and phone number address below.

Thanks in advance.

James Jackson
813-828-4628
jacksj1@socom.mil


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Comparison jroxit Classic ASP Databases 5 October 5th, 2007 05:39 PM
Date comparison rajuru Beginning PHP 2 February 19th, 2005 10:33 AM
Date comparison lily611 General .NET 5 January 4th, 2005 07:08 AM
Date Comparison hoffmann Classic ASP Databases 7 October 21st, 2004 09:00 AM
Date Comparison cmiller PHP How-To 3 June 19th, 2003 02:58 PM



All times are GMT -4. The time now is 06:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.