I am encountering an error when trying to run the below... I get a "Invalid use of null" It appears if ANY of the fields are empty this wont work. This is one of a few like it that copies related records under a duplicate quote button... Is there a way in the below to allow null values and just insert nothing if blank??
If DCount("[QUOTEID]", "Subquote", "QUOTEID=" & IdToCopy & "") > 0 Then
SubQuoteSQL = "INSERT INTO [SubQuote]" & _
" ( QuoteID , TYPEOFQUOTE , Quantity," & _
" CargoType,CargoDescription,QuoteLen, QuoteWid, QuoteHgt, QuoteWgt, " & _
" SubNotes,Datecreated, QuoteCuft,Exclude)" & _
" SELECT " & LongNewID & " As QuoteID, TYPEOFQUOTE, Quantity, CargoType, CargoDescription, " & _
" QuoteLen, QuoteWid, QuoteHgt, QuoteWgt, SubNotes," & "#" & TodayDate & "#" & " as Datecreated, QuoteCuft,Exclude" & _
" FROM SubQuote " & _
" WHERE (QuoteID = " & IdToCopy & ");"
'Debug.Print SubQuoteSQL
DB.Execute (SubQuoteSQL), dbFailOnError
Else
'Do Nothing
End If
If DCount("[QUOTEID]", "Subquote", "QUOTEID=" & IdToCopy & "") > 0 Then
SubQuoteSQL = "INSERT INTO [SubQuote]" & _
" ( QuoteID , TYPEOFQUOTE , Quantity," & _
" CargoType,CargoDescription,QuoteLen, QuoteWid, QuoteHgt, QuoteWgt, " & _
" SubNotes,Datecreated, QuoteCuft,Exclude)" & _
" SELECT " & LongNewID & " As QuoteID, TYPEOFQUOTE, Quantity, CargoType, CargoDescription, " & _
" QuoteLen, QuoteWid, QuoteHgt, QuoteWgt, SubNotes," & "#" & TodayDate & "#" & " as Datecreated, QuoteCuft,Exclude" & _
" FROM SubQuote " & _
" WHERE (QuoteID = " & IdToCopy & ");"
'Debug.Print SubQuoteSQL
DB.Execute (SubQuoteSQL), dbFailOnError
Else
'Do Nothing
End If