?
Solved

Help with blank field in record

Posted on 2003-03-03
2
Medium Priority
?
167 Views
Last Modified: 2010-04-17
Hi,

I'm trying to write a code that checks for the field TDate in a record, if the TDate field is empty or null, then assigned the current date to the TDate, if date already exist, just display the date. The problem is if the date is empty it does not assign the date, it will just display "Date is         " What do I need to check for to make it assign a date?


Private Sub TDate_click()
    If Me.TDate = Null Then
        Me.TDate = Date
    Else
        MsgBox "Date is " & Me.TDate & ""
    End If
End Sub

I've tried also using

If Me.TDate = "" Then

0
Comment
Question by:Fr3aK
[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
2 Comments
 
LVL 6

Accepted Solution

by:
hans_vd earned 80 total points
ID: 8063405
Why don't you try this:

'IsDate checks whether your variable holds an valuable Date
Private Sub TDate_click()
   If IsDate(Me.TDate) Then
       Me.TDate = Date
   Else
       MsgBox "Date is " & Me.TDate & ""
   End If
End Sub


or this:

'You can use 'Or' in an If statement to perform two checks
'Use the function IsNull instead of '... = Null'
Private Sub TDate_click()
   If IsNull(Me.TDate) Or Me.TDate = "" Then
       Me.TDate = Date
   Else
       MsgBox "Date is " & Me.TDate & ""
   End If
End Sub
0
 
LVL 1

Expert Comment

by:MarkKoro
ID: 8063909
If you have your fields defined as dates and they are not null than this code should work...

Private Sub TDate_click()
   dim ChkDate as date
   If Me.TDate = ChkDate Then
       Me.TDate = Date
   Else
       MsgBox "Date is " & Me.TDate & ""
   End If
End Sub

 
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Six Sigma Control Plans
Introduction to Processes

764 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