[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

DateDiff -- Type mismatch

Posted on 2002-05-13
6
Medium Priority
?
725 Views
Last Modified: 2008-03-17
Have 2-txtboxes, where user enters date. I'd like to know the number of days between the entered dates:

If DateDiff("d", Me!txt0, Me!txt1) > 5 Then
Msgbox "5+"
End If

but I'm getting "Type MisMatch"

any ideas....
0
Comment
Question by:debbie790
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7006032
This can only be if the value in the textboxes is not a valid date

Try to check using the IsDate(Me!txt0.Text) if the value is recognized as a date or not.

CHeers
0
 
LVL 12

Accepted Solution

by:
Paurths earned 200 total points
ID: 7006033
try

If DateDiff("d", CDate(Me!txt0), CDate(Me!txt1)) > 5 Then
Msgbox "5+"
End If

cheers
Ricky

0
 
LVL 44

Expert Comment

by:bruintje
ID: 7006048
Hi Debbie790,

-you should be sure there are dates entered in the textboxes
-make their format property something like short date
-and then you can do something like

If DateDiff("d", CDate(Me!Txt0), CDate(Me!Txt1)) > 5 Then

-and better rename your date boxes to something meaningful for easier reading

HTH:O)Bruintje
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 44

Expert Comment

by:bruintje
ID: 7006051
next i'll refresh first :)
0
 
LVL 1

Expert Comment

by:emorrie
ID: 7006098
DateDiff works on Date/Time field values.  It does not convert Text fields to Date/Time on the fly.  You can try the CDate function to convert a text string to a date before using datediff.

If DateDiff("d", CDate(Me!txt0), CDate(Me!txt1))>5 Then
    Do stuff here
End If
0
 
LVL 1

Expert Comment

by:emorrie
ID: 7006117
same here bruintje.

Sorry for the duplicate info
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question