473,386 Members | 1,823 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,386 software developers and data experts.

Querying dates of two fields.

I'm not sure if I've disribed this right but this is what I need:

I have two fields with dates in.

I need some code that will look at the two dates and if the dates are more than four days apart then a warning message of some type with display saying that its been four or more days.

I have my database made, and I've made a form for viewing and inputing the records.

I've looked around everywhere to see if I can find an answer but as I'm not very experianced with Access I've come looking here requesting for help.

Any help will will be greatly appreciated.
Mar 19 '08 #1
5 1331
missinglinq
3,532 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. If Not IsNull(Me.FirstDate) and Not IsNull(Me.SecondDate) Then
  2.   If DateDiff("d", Me.FirstDate, Me.SecondDate) > 4 Then
  3.     MsgBox "It's been more than 4 days !"
  4.   End If
  5. End If
  6.  
You don't say when you want this message to popup. If you want it to popup after entering one of these dates, place it in the AfterUpDate event for the textbox. If you want it to popup when moving to a record, place it in the Form_Current event.

Welcome to TheScripts!

Linq ;0)>
Mar 19 '08 #2
Expand|Select|Wrap|Line Numbers
  1. If Not IsNull(Me.FirstDate) and Not IsNull(Me.SecondDate) Then
  2.   If DateDiff("d", Me.FirstDate, Me.SecondDate) > 4 Then
  3.     MsgBox "It's been more than 4 days !"
  4.   End If
  5. End If
  6.  
You don't say when you want this message to popup. If you want it to popup after entering one of these dates, place it in the AfterUpDate event for the textbox. If you want it to popup when moving to a record, place it in the Form_Current event.

Welcome to TheScripts!

Linq ;0)>
Hey, Thanks for the bit of code. I'm still having problems and feeling abit like an idiot at the moment.

This is what I have got at the moment:

Private Sub Site_Survey_Date_A(Form_Current)

If Not IsNull(Me.Site_Survey_Date_A) And Not IsNull(Me.G_A_Completion_Date_A) Then
If DateDiff("d", Me.Site_Survey_Date_A, Me.G_A_Completion_Date_A) > 4 Then
MsgBox "It's been more than 4 days !"
End If

End If

End Sub

Which probably is totally wrong, but I'm getting nothing, and I haven't a clue what I'm doing really. Should the code go into section for the actual field or for the general form or what? I'm sorry but as I said before I'm kinda clueless.

I think I have explained it wrong also. I believe what I need instead of what I originally described is:

If there hasn't been a date inputted in since the date inputted in the other field then it should warn me.

I've only just realised what I've said. Sorry about that.
Mar 19 '08 #3
Right, after much confusion this is what I basically need

If DateRecieved is not null and SiteSurvey is Null

Then

If Date difference "DateRecieved" and "TodaysDate" day is More than 4 different

Then

MessageBox "Site Survey field not completed after Four days!"

End


I know this isnt VB or Access code, its just basically what I need to be code. Any help would be greatly appreciated, I've been messing around most of the day and still gotten no where. Also I dont know what sub to put the code in, whether its the form or the actual SiteSurvey box
Mar 19 '08 #4
I DID IT!!

Thanks for the previous code, it helped alot!

Here is the code did what I wanted it to do:
  1. Private Sub Form_Current()

    If Not IsNull(Me.DateRecieved) And IsNull(Me.SiteSurvey) Then

    If DateDiff("d", Me.DateRecieved, Me.TodayDate) > 4 Then
    MsgBox "Warninig Site Survey Date hasn't been completed after four days!"

    End If
    End If

    If Not IsNull(Me.SiteSurvey) And IsNull(Me.GACompletion) Then

    If DateDiff("d", Me.SiteSurvey, Me.TodayDate) > 4 Then
    MsgBox "Warninig G.A. Completion Date hasn't been completed after four days!"

    End If
    End If

    End Sub

Thanks again!
Mar 19 '08 #5
missinglinq
3,532 Expert 2GB
Glad you figured out what you actually needed and got it working!

Linq ;0)>
Mar 19 '08 #6

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

Similar topics

8
by: netsurfer | last post by:
Hi: Have a question on making the date automatically filled in by what the user enters in by the date at the top. The date entered at the top would most likely be on a Wednesday then I need...
2
by: toedipper | last post by:
Hello, MYsql and PHP If I want to extract data with todays date then it's 'where blab blah = current_date()' For yesterday it's 'where blah blah = current_date()-1' But can anyone tell...
7
by: smcgouga | last post by:
Visual Basic 6. ADO 2.8 I have an as400 DB2 V5R1 datasource. Dates are defined as *ISO format and have a range from '0001-01-01' to '9999-12-31'. I am trying to update a date field on the...
4
by: Stewart Allen | last post by:
I'm trying to filter a table that has 2 date fields, the first date will always have a value but the second will only occasionally has a value. Each date field also has a corresponding text field...
4
by: reidarT | last post by:
I want to show data objects as Y-axis (rows) and dates alng x-axis (fields) Date 01.01.05 02.01.05 03.01.05 ... Obj1 Free Free Occupied Obj2 Free ...
10
by: John | last post by:
Hi I have a form with tow fields for dates in dd/mm/yyyy format. I am trying to use the fields in a query's where clause as below; "SELECT * " & _ "FROM Orders " & _ " WHERE Orders.)>= #" &...
4
by: minapatel | last post by:
Probably a simple solution but can't find it myself can someone help????? I would like to extract data from a table where the dates are between two dates and then loop to select more data for...
4
by: Jeff Goodman | last post by:
If there is a better newsgroup to post this in, please let me know. I am a relatively new VB.NET/SQL 2000 programmer. I am working with data imported into SQL2K from Access. Many of the dates...
3
by: myemail.an | last post by:
If I need to format how the content of a field is displayed, I can click ALT + ENTER from design view, and specify the format, for example, the number of decimal digits and so on. Is there a way...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...

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.