SQL Error - Invalid use of Null INSERT INTO

kwhite100

Board Regular
Joined
Aug 18, 2010
Messages
91
Hello team,

I have a co-worker out on vacation and I was asked to step in and find the issue with this statement below. We have an excel add-in that has a excel module with the following code:

I get error -2147217900


Code:
Function ImportProgressSql() As String
    ImportProgressSql = _
        "INSERT INTO DrawingProgress(DrawingId, ProgressId, Progress, ProgressDate, EntryDate) " & vbCrLf & _
        "SELECT DrawingId, ProgressTypeId, Progress, DataDate, Now() AS EntryDate " & vbCrLf & _
        "  FROM ((tmpJuniorProgress" & Environ("USERNAME") & " jp " & vbCrLf & _
        "    LEFT JOIN Drawings d " & vbCrLf & _
        "      ON jp.ContractorDrawingId = d.ContractorDrawingId) " & vbCrLf & _
        "    LEFT JOIN DrawingProgressType pt " & vbCrLf & _
        "      ON jp.ProgressTypeName = pt.ProgressTypeName)  " & vbCrLf & _
        "  WHERE CStr(DrawingId) + CStr(ProgressTypeId) + CStr(Progress) + CStr(DataDate) " & vbCrLf & _
        "    NOT IN (SELECT CStr(DrawingId) + CStr(ProgressTypeId) + CStr(Progress) + CStr(DataDate) FROM DrawingProgress)"[COLOR=#333333]
[/COLOR]


My first instinct is to look at syntac..syntax looks alright. Second would be to make sure the columns exists in the tables..I will list the current columns out for the tables in questions:

Table 1 - DrawingProgress(ProgressDrawingID, DrawingID, ProgressID, Progress, ProgressDate, EntryDate)
Table 2 - tmpJuniorProgress(ContractorDrawingID, ProgressTypeName, Weight, DataDate, Progress)
Table 3 - DrawingProgressType(ProgressType, ProgressTypeName)

I think there may be an invalid value type in the DrawingProgressType Table. Does anyone see anything that sticks out? Thank you again for assisting. Just trying to step in an assist someone who is out.


Cross-posted: http://www.mrexcel.com/forum/excel-...l-sql-error-invalid-use-null-insert-into.html
 
Last edited by a moderator:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,215,325
Messages
6,124,252
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top