Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default VBA & SQL: INSERT TO... problem with date

How can I insert a blank field into a date field in Access?

For example, I have a Table with the fields Name, Surname, Birthday(Date).

I'd like to insert a new record based on an excel sheet using ADO & SQL
String. If the birthday field is empty I get an error. The value is ##
because the field is empty.

SQLstring = "INSERT INTO TABLE(NAME, SURNAME, BIRTHDAY) VALUES('Johnny',
'Walker', ##)"

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default VBA & SQL: INSERT TO... problem with date

Presumably the Access table allows nulls for birthday?

If so, just use

SQLstring = "INSERT INTO TABLE(NAME, SURNAME) VALUES('Johnny', 'Walker')"


--
HTH

Bob Phillips

"Santiago" wrote in message
...
How can I insert a blank field into a date field in Access?

For example, I have a Table with the fields Name, Surname, Birthday(Date).

I'd like to insert a new record based on an excel sheet using ADO & SQL
String. If the birthday field is empty I get an error. The value is ##
because the field is empty.

SQLstring = "INSERT INTO TABLE(NAME, SURNAME, BIRTHDAY) VALUES('Johnny',
'Walker', ##)"

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default VBA & SQL: INSERT TO... problem with date

Thanks Bob,

the problem is that this code is in the middle of other code, so I should
check if the field is empty or not, etc...

is there any way to insert a Null value? For Text or number you just put two
single quotes ('') and that's it. For dates?

Thanks.

"Bob Phillips" wrote:

Presumably the Access table allows nulls for birthday?

If so, just use

SQLstring = "INSERT INTO TABLE(NAME, SURNAME) VALUES('Johnny', 'Walker')"


--
HTH

Bob Phillips

"Santiago" wrote in message
...
How can I insert a blank field into a date field in Access?

For example, I have a Table with the fields Name, Surname, Birthday(Date).

I'd like to insert a new record based on an excel sheet using ADO & SQL
String. If the birthday field is empty I get an error. The value is ##
because the field is empty.

SQLstring = "INSERT INTO TABLE(NAME, SURNAME, BIRTHDAY) VALUES('Johnny',
'Walker', ##)"

Thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default VBA & SQL: INSERT TO... problem with date


use the Null keyword.


"INSERT INTO TABLE(NAME, SURNAME, BIRTHDAY)
VALUES('Johnny', 'Walker', Null)"



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Santiago wrote :

How can I insert a blank field into a date field in Access?

For example, I have a Table with the fields Name, Surname,
Birthday(Date).

I'd like to insert a new record based on an excel sheet using ADO &
SQL String. If the birthday field is empty I get an error. The value
is ## because the field is empty.

SQLstring = "INSERT INTO TABLE(NAME, SURNAME, BIRTHDAY)
VALUES('Johnny', 'Walker', ##)"

Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default VBA & SQL: INSERT TO... problem with date

Thanks KIC, I believe I tried that and did not work, but maybe the problem
was another one. For "UPDATE" SQL command Null seems to work, so should also
work for "INSERT INTO" command.

I'll try again and recheck. Thanks

"keepITcool" wrote:


use the Null keyword.


"INSERT INTO TABLE(NAME, SURNAME, BIRTHDAY)
VALUES('Johnny', 'Walker', Null)"



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Santiago wrote :

How can I insert a blank field into a date field in Access?

For example, I have a Table with the fields Name, Surname,
Birthday(Date).

I'd like to insert a new record based on an excel sheet using ADO &
SQL String. If the birthday field is empty I get an error. The value
is ## because the field is empty.

SQLstring = "INSERT INTO TABLE(NAME, SURNAME, BIRTHDAY)
VALUES('Johnny', 'Walker', ##)"

Thanks


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I insert a date with an icon (calendar) insert Alfredo Mederico[_2_] Excel Discussion (Misc queries) 4 September 21st 07 01:20 AM
insert row problem WYN Excel Discussion (Misc queries) 3 June 30th 05 05:46 AM
Automatically Insert DATE, so that DATE will NOT change Cie Excel Worksheet Functions 4 April 4th 05 05:51 PM
Insert\Name\Apply.... problem David Excel Worksheet Functions 6 February 25th 05 12:49 PM
copy insert problem saziz[_10_] Excel Programming 4 June 25th 04 01:50 AM


All times are GMT +1. The time now is 03:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"