Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL INSERT Date is Null

Status
Not open for further replies.

DSTR3

Technical User
Jan 21, 2005
41
US
I'm having a problem inserting a record if the date field empty, It only works if there is a Date in the Me.TxtDate, otherwise I get an Error.

I tried this but, it doesn't work.

Thanks
DS


CurrentDb.Execute "INSERT INTO Table1 (ID,DateF) " & _
"VALUES(" & Forms!Form1!TxtID & ", " & _
"" & Nz("#" & Me.TxtDate & "#", "Null") & ")
 
Try this in the Microsoft:access Queries and JET SQL forum, you may get a reply.


Ian Mayor (UK)
Program Error
Programming is 1% coding, 50% error checking and 49% sweat as your application bombs out in front of the client.
 
How are ya DSTR3 . . .

Perhaps this:
Code:
[blue]   Dim SQL As String
   
   SQL = "INSERT INTO Table1 (ID,DateF) " & _
         "VALUES(" & Forms!Form1!TxtID & ", " & _
                 Nz(Me.TxtDate, "Null") & ")"
   CurrentDb.Execute SQL[/blue]

Calvin.gif
See Ya! . . . . . .
 
#" & Me.TxtDate & "#" is NEVER null !
CurrentDb.Execute "INSERT INTO Table1 (ID,DateF) " & _
"VALUES(" & Forms!Form1!TxtID & ", " & _
"" & Nz("#" [!]+[/!] Me.TxtDate [!]+[/!] "#", "Null") & ")"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Aceman, it almost works....it returns time, not date.

Phv, Works perfectly!

Thanks
DS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top