Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Problem with update query

Author  Topic 

sven2
Yak Posting Veteran

57 Posts

Posted - 2009-11-09 : 04:30:25
Hello,

when I update a record like this:

strSQL = " UPDATE employee SET Firstname = '" & [Forms]![Frmemployee]![txtname] & "'" ... etc.

the problem is that I loose the null value where the fields are empty.

How can I make it so that when a field is empty the value in the table becomes Null ?

Thanks in advance,
Sven.








madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-09 : 04:35:45
Validate it in the form and send NULL value if needed

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-11-09 : 04:37:42
Try like this..


update tables set first_name= nullif(first_name,'') where .....

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-09 : 10:51:50
strSQL = " UPDATE employee SET Firstname = NULLIF('" & [Forms]![Frmemployee]![txtname] & "','')" ... etc.
Go to Top of Page
   

- Advertisement -