473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Reseting a variable intOldDate As Date to null

RobH
56
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 - DateAppointmentSet

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.
Sep 24 '07 #1
2 16804
cyberdwarf
218 Expert 100+
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
Expand|Select|Wrap|Line Numbers
  1. Dim DateVar As Date
  2. DateVar = Empty
  3. If DateVar = "00:00:00" Then
  4.      debug.print "Empty"
  5. Else
  6.      debug.print DateVar
  7. End If
You can set the date to a negative number, if you wish

HTH

Steve
Sep 24 '07 #2
RobH
56
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
Expand|Select|Wrap|Line Numbers
  1. Dim DateVar As Date
  2. DateVar = Empty
  3. If DateVar = "00:00:00" Then
  4.      debug.print "Empty"
  5. Else
  6.      debug.print DateVar
  7. 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
Sep 24 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: Jason Curl | last post by:
I've been reading this newsgroup for some time and now I am thoroughly confused over what NULL means. I've read a NULL pointer is zero (or zero typecast as a void pointer), others say it's...
2
by: Fred Nelson | last post by:
Hi: Another C# newby question: How do I declare a null DateTime variable: DateTime myDate = null; I get the error:
5
by: Kermit Piper | last post by:
Hello, I am comparing two date values, one from a database and one that has been converted from a hard-coded string into an actual Date type. So far so good. The problem I'm having is that one...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
3
by: Jay | last post by:
Hi, I am working on a web service project. To start with i get the data frm the web service and populate all the objects with the values received. In the second step i display the data received on...
2
by: boyleyc | last post by:
Hi all the following code works perfectly well. Basically it populates a series of check boxes on my form, depending on whether dlookup finds an associated record. The problem i have is that...
1
by: SilviaLl | last post by:
Hello, I've a textbox binded with a date field. The problem is when I clear the textbox the old value is set. In the parse event: Select Case sender.control.FieldType Case...
0
by: Scott | last post by:
I have a report that summarizes attendance occurances for my team of 50 employees. Right now the date values are entered by the user before report execution. I want the start date to be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.