PC Review


Reply
Thread Tools Rate Thread

cdate problem

 
 
JohnP
Guest
Posts: n/a
 
      1st Apr 2008
Hi,

I have some code for user forms that require date entry. Some of the date
fields can be left blank but when the code runs it errors out because my code
refers to a blank variable as a cdate. I have phrased this statement within
an if so that it should only run if the date field is not blank but it still
comes up as a type mismatch error.

Any ideas? Let me know if you need more explanation.

Thanks in advance for any help you can offer.

JohnP
 
Reply With Quote
 
 
 
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      1st Apr 2008
It would help if you could show us your code.

Rick


"JohnP" <(E-Mail Removed)> wrote in message
news:B53BBCF3-3AC9-4034-973E-(E-Mail Removed)...
> Hi,
>
> I have some code for user forms that require date entry. Some of the date
> fields can be left blank but when the code runs it errors out because my
> code
> refers to a blank variable as a cdate. I have phrased this statement
> within
> an if so that it should only run if the date field is not blank but it
> still
> comes up as a type mismatch error.
>
> Any ideas? Let me know if you need more explanation.
>
> Thanks in advance for any help you can offer.
>
> JohnP


 
Reply With Quote
 
JohnP
Guest
Posts: n/a
 
      1st Apr 2008
Hi Rick,

See code section below. I know its not the best. Still quite new to this!

Thanks,

If FromFullDate.Value <> "" Then
Sheets("Template").Select
Range("A9").Activate
j = 9
While CDate(ActiveCell.Value) <> CDate(FromFullDate.Value)
ActiveCell.Offset(1, 0).Activate
j = j + 1
Wend
If ActiveCell.Interior.ColorIndex = 1 Then
Application.ScreenUpdating = True
MsgBox Prompt:="" & CDate(FromFullDate.Value) & " is a weekend or a bank
holiday. Please select a weekday.", _
Buttons:=vbOKOnly + vbExclamation
FromFullDate = ""
Exit Sub
End If
End If

"Rick Rothstein (MVP - VB)" wrote:

> It would help if you could show us your code.
>
> Rick
>
>
> "JohnP" <(E-Mail Removed)> wrote in message
> news:B53BBCF3-3AC9-4034-973E-(E-Mail Removed)...
> > Hi,
> >
> > I have some code for user forms that require date entry. Some of the date
> > fields can be left blank but when the code runs it errors out because my
> > code
> > refers to a blank variable as a cdate. I have phrased this statement
> > within
> > an if so that it should only run if the date field is not blank but it
> > still
> > comes up as a type mismatch error.
> >
> > Any ideas? Let me know if you need more explanation.
> >
> > Thanks in advance for any help you can offer.
> >
> > JohnP

>
>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      1st Apr 2008
While the code is not how I would have written it, it appears to work fine
from the test I did. Tell us *exactly* what problem are you having that
prompted you to ask your question (give details so we can reproduce the
problem on our own computers)?

Rick


"JohnP" <(E-Mail Removed)> wrote in message
news:B53BBCF3-3AC9-4034-973E-(E-Mail Removed)...
> Hi,
>
> I have some code for user forms that require date entry. Some of the date
> fields can be left blank but when the code runs it errors out because my
> code
> refers to a blank variable as a cdate. I have phrased this statement
> within
> an if so that it should only run if the date field is not blank but it
> still
> comes up as a type mismatch error.
>
> Any ideas? Let me know if you need more explanation.
>
> Thanks in advance for any help you can offer.
>
> JohnP


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CDATE Problem mattc66 via AccessMonster.com Microsoft Access Queries 3 6th Oct 2006 09:50 PM
CDate Problem sil0000 Microsoft Excel Programming 7 22nd Jul 2005 08:24 AM
cdate problem Stephen Microsoft VB .NET 2 13th Jan 2005 01:44 AM
CDate problem David Schwartz Microsoft VB .NET 12 9th Feb 2004 02:38 PM
Re: Problem with CDATE() in .NET Armin Zingler Microsoft VB .NET 0 25th Sep 2003 04:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:13 PM.