[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

DateDiff -- Type mismatch

Posted on 2002-05-13
6
Medium Priority
?
722 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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