Originally Posted by
pwalter83
Hi,
I am created a form to add row of data to a table (Access 2007). The form has been completed and tested and seems to be working perfectly in terms of adding row of data to a table and updating also works fine.
However, the problem I am facing is that when I try to edit the form (design view) or close the form, it gives an error:
------------------------------------------
ODBC --call failed
Cannot Insert the value NULL into the column. Column does not allow nulls. INSERT fails. The statement has been terminated.
------------------------------------------
When this error starts to appear, I am unable to view the form in design view or save it. But I am able to make entries to the table.
I am using this VBA code for the 'Add Record' button:
----------------------------------------------------------
Private Sub Add_Record_Click()
Dim strSQL As String
' ******************************************
If NOT isnull(me!Text41) AND Not isnull(me!Text45) then
' ****************************************
strSQL = "INSERT INTO dbo_VESSEL (VESSEL_NAME, VESSEL_CD,VOYAGE_NUM, LINE_CD, PORT_CD,DEPART_ACTUAL_DT,DIVISION_CD ) VALUES ('" & Me!VESSEL_NAME & "', '" & Me!VESSEL_CD & "','" & Me!VOYAGE_NUM & "', '" & Me!Text41 & "', '" & Me!PORT_CD & "', '" & Me!DEPART_ACTUAL_DT & "', '" & Me!Text45 & "');"
DoCmd.RunSQL strSQL
' *******************************
end If
' *******************************
End Sub
------------------------------------------------------------
Does anyone know why this error appears while closing or editing the form ?
Thanks !
Paul