473,789 Members | 2,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to blank out a field of a date/time data type

Hi,

I was trying to blank out (null out?) a field of a record that is a
date/time data type. Here is code excerpt:

Dim D As Database
Dim rsRacks As Recordset
Dim strSQL As String

strSQL = "SELECT Racks.* FROM Racks WHERE (((Racks.[RL-Serial])= "
& RackSerial & "));"
Set D = CurrentDb
Set rsRacks = D.OpenRecordset (strSQL, DB_OPEN_DYNASET )

If rsRacks.RecordC ount > 0 Then
rsRacks.Edit
rsRacks![DateShipped] = ""
rsRacks![TimeShipped] = ""
Else
rsRacks.AddNew
rsRacks![RL-Serial] = RackSerial
End If

rsRacks.Update
rsRacks.Close

This code gets a type conversion error. The problem lines is where the
DateShipped and TimeShipped are set to "". I also tried "##". Does
anyone have any ideas?

Thanks in advance,
Aaron

Nov 13 '05 #1
1 2833
Try using Null. Of course, that will only work if the field is marked as not
being required.

If is required, Date fields are actually numbers (8 byte floating point
numbers, where the integer part represents the date as the number of days
related to 30 Dec, 1899, and the decimal part represents the time as a
fraction of a day). You'd have to set the fields to a numeric value,
preferably one that can't occur naturally!

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

<ha***********@ hotmail.com> wrote in message
news:11******** ************@o1 3g2000cwo.googl egroups.com...
Hi,

I was trying to blank out (null out?) a field of a record that is a
date/time data type. Here is code excerpt:

Dim D As Database
Dim rsRacks As Recordset
Dim strSQL As String

strSQL = "SELECT Racks.* FROM Racks WHERE (((Racks.[RL-Serial])= "
& RackSerial & "));"
Set D = CurrentDb
Set rsRacks = D.OpenRecordset (strSQL, DB_OPEN_DYNASET )

If rsRacks.RecordC ount > 0 Then
rsRacks.Edit
rsRacks![DateShipped] = ""
rsRacks![TimeShipped] = ""
Else
rsRacks.AddNew
rsRacks![RL-Serial] = RackSerial
End If

rsRacks.Update
rsRacks.Close

This code gets a type conversion error. The problem lines is where the
DateShipped and TimeShipped are set to "". I also tried "##". Does
anyone have any ideas?

Thanks in advance,
Aaron

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
7018
by: Joe Scully | last post by:
Hi all, I am having trouble with access adding a blank record to a subform everytime I finish entering data and closing the form. (The form and subform are based on the one table) When entering data into the subform I get the pencil icon to show data addition, but underneath the record I am inputting data the record is blank with a star(*)icon and this is the record(blank)that always gets saved with all the records that actually have...
5
4306
by: Javier | last post by:
I have a field type Date/Time that automatically defaults to Now(). I'm having a problem writing a query that will retrieve all the records for a specific date the user to enters when prompted. I could retrieve all the records for a specific date if I hard-code the date into the query, but not if I want to prompt the user. Has anybody else experienced this? Does anybody have any suggestions?
8
3125
by: MacDermott | last post by:
I have a query, which gathers up information, which is subsequently dumped into an instance of Excel using recordsetcopy. For one of the query fields, I have written what should be a pretty simple little function with three arguments, a switch (integer) and 2 date fields. For certain values of the switch, I use one date field, for others, the other date field, and for switch values which are neither, I need to return a blank. Well,...
11
5934
by: Dixie | last post by:
How can I programatically, take some Date/Time fields present in a table in the current database and change their type to text? dixie
5
3052
by: Øyvind Isaksen | last post by:
I have a page with an optional integer-field, and one asp:calendar control. I use a stored procedure to save the data in SQL Server. When all fields contains data, the code works great! But if the user dont fill in the optional "price-field" (integer value), or if the user dont choose a date in the asp:calendar control, I get the message "Input string was not in a correct format". How do I save "Null" value if the price-field is blank,...
1
1925
by: Rick | last post by:
I'm trying to do a SELECT statement looking for a DATE_COMPLETED field which is blank, meaning it has not been completed. The DATE_COMPLETED field is a DATE type field. How do I specify my WHERE conditiion to restrict the results to only those records which have no DATE_COMPLETED data in them? Thanks in advance, Rick
4
2217
by: sparks | last post by:
I am trying to fix a database that someone did about 4 yrs ago in access97. The main table just contains demographics and is on the main form of the database. It has a subform on a tab that contains the other information. it is set 1 to 1 in the relationships. simplify if I can
5
2710
by: M Skabialka | last post by:
I am creating my first Visual Studio project, an inventory database. I have created a form and used written directions to add data from a table to the form using table adapters, data sets, etc. I imported a table from an Access database which has some date fields. Many of these dates have never been filled in, so are nulls. If I look directly into the table data from Visual Studio it shows NULL. However, when I scroll from record to...
2
2565
by: dympna | last post by:
Hi can anyone suggest a fix for this... as I am a novice in access. I have created a training table with the following fields Employee Name - joe Training Received - Fork lift Date Received - 20/6/07 Certificate - yes What I want to create is a renewal date for this training, there are
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9016
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.