Reseting a variable intOldDate As Date to null

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RobH
    New Member
    • Jul 2007
    • 56

    Reseting a variable intOldDate As Date to null

    I need to reset a variable inOldDate which was set as a Date back to null.

    In my module1 if have
    Public intOldDate As Date

    I have a form with a field (AppoinmentDate ) which on gotfocus copies the current value of AppointmentDate to the variabe intOldDate the form has a submit button (save) that compares the difference between intOldDate and the value when the save button is pressed. If the value is different then the currentdate gets written to another field - DateAppointment Set

    The problem I have is that the first time they do this its fine. The second time through the previous value remains in intOldDate - I need to be able to reset the variable to Null or whatever the default value should be.
  • cyberdwarf
    Recognized Expert New Member
    • Nov 2006
    • 218

    #2
    Setting the date variable = 0 will give you a date of 30/12/1899. This will probably be OK for most purposes, provided you use the correct comparison value.

    Setting a date to Empty gives you the uninitialised value 00:00:00 (This is my preferred method). You can check for this by using
    Code:
    Dim DateVar As Date
    DateVar = Empty
    If DateVar = "00:00:00" Then
    	 debug.print "Empty"
    Else
    	 debug.print DateVar
    End If
    You can set the date to a negative number, if you wish

    HTH

    Steve
    Last edited by cyberdwarf; Sep 24 '07, 09:10 AM. Reason: Correction

    Comment

    • RobH
      New Member
      • Jul 2007
      • 56

      #3
      Originally posted by cyberdwarf
      Setting the date variable = 0 will give you a date of 30/12/1899. This will probably be OK for most purposes, provided you use the correct comparison value.

      Setting a date to Empty gives you the uninitialised value 00:00:00 (This is my preferred method). You can check for this by using
      Code:
      Dim DateVar As Date
      DateVar = Empty
      If DateVar = "00:00:00" Then
      	 debug.print "Empty"
      Else
      	 debug.print DateVar
      End If
      You can set the date to a negative number, if you wish

      HTH

      Steve
      I sort of came to my own version of this same process by setting the variable to a known Variable date of 1/1/2000 and as you indicated I check against that.

      Probably not as pretty and Industry standardised as the solution you have provided - but thanks

      Comment

      Working...