B
BobV
Group:
I have the following sub in one of my modules. When one of the dates that
are passed through to the sub is a Null, the sub enters a date of
"12/30/1899" into the table.
For example, when the PriorSYBegDate variable in my sub is nonexistant
(null), then I want the sub to make no entry into the table for this
variable. If a zero is entered, then I get a date of "12/30/1899" entered
into the table.
How do I get the sub to enter nothing when the date is null?
Thanks,
BobV
'INSERT INTO TABLES
Sub InsertIntoTable(CompanyName As String, BegDate As Date, EndDate As Date,
PriorSYBegDate As Date, PriorSYEndDate As Date)
Dim BackDb As DAO.Database
Dim strSQL As String
Dim PathName As String
On Error Resume Next
PathName = fGetPathName
Set BackDb = OpenDatabase(PathName & "\Asset Database.mdb")
strSQL = "INSERT INTO [MasterData](Name, Beginning, Ending,
PriorSYBeginning, PriorSYEnding, EIN, Sec179Carryover, BusIncome) VALUES
(""" & CompanyName & """, #" & BegDate & "#, #" & EndDate & "#, #" &
nz(PriorSYBegDate) & "#, #" & nz(PriorSYEndDate) & "#, ""95-1234567"", 0,
0);"
BackDb.Execute strSQL, dbFailOnError
Set BackDb = Nothing
End Sub
I have the following sub in one of my modules. When one of the dates that
are passed through to the sub is a Null, the sub enters a date of
"12/30/1899" into the table.
For example, when the PriorSYBegDate variable in my sub is nonexistant
(null), then I want the sub to make no entry into the table for this
variable. If a zero is entered, then I get a date of "12/30/1899" entered
into the table.
How do I get the sub to enter nothing when the date is null?
Thanks,
BobV
'INSERT INTO TABLES
Sub InsertIntoTable(CompanyName As String, BegDate As Date, EndDate As Date,
PriorSYBegDate As Date, PriorSYEndDate As Date)
Dim BackDb As DAO.Database
Dim strSQL As String
Dim PathName As String
On Error Resume Next
PathName = fGetPathName
Set BackDb = OpenDatabase(PathName & "\Asset Database.mdb")
strSQL = "INSERT INTO [MasterData](Name, Beginning, Ending,
PriorSYBeginning, PriorSYEnding, EIN, Sec179Carryover, BusIncome) VALUES
(""" & CompanyName & """, #" & BegDate & "#, #" & EndDate & "#, #" &
nz(PriorSYBegDate) & "#, #" & nz(PriorSYEndDate) & "#, ""95-1234567"", 0,
0);"
BackDb.Execute strSQL, dbFailOnError
Set BackDb = Nothing
End Sub