R
rocco
Hello folks,
I have an unbound form with 3 controls:
a combobox [epyear] where only values in the list can be chosen; a checkbox
(ephospital] and a textbox [eptime].
I have the line of code below which will fire up when user hit a command
button that confirm what has been entered in the 3 controls mentioned.
Code is:
If IsNull(Epyear) = False And IsNull(ephospital) = False And
IsNull(eptime) = False Then
Application.CurrentDb.Execute ("INSERT INTO TBLANAMPSICHIATRICA
(ID,EPYEAR,EPHOSPITAL,EPTIME) VALUES('" & Me.id & "'," & Epyear & "," &
ephospital & "," & eptime & ")")
End if
Eptime should be filled with data ONLY if the checkbox has been checked, so
it is possible that it has to be left blank and the checkbox unchecked.
But in this case I’m not able to have the SQL line working.
It seems that I HAVE TO provide a number for Eptime: it doesn’t allow for
Null.
Many books say that if a column is mentioned in the INSERT INTO statement
than a value HAVE TO be provided for each column. If there’s no values than
Null should be used. But my statement will pass a Null (since the control has
been left blank).
And this happen only with fields in the table that expect number datatype.
Sounds like you cannot assign a Null value through SQL to a numeric field.
Please can someone explain this messy thing?
Thanks
Rocco
I have an unbound form with 3 controls:
a combobox [epyear] where only values in the list can be chosen; a checkbox
(ephospital] and a textbox [eptime].
I have the line of code below which will fire up when user hit a command
button that confirm what has been entered in the 3 controls mentioned.
Code is:
If IsNull(Epyear) = False And IsNull(ephospital) = False And
IsNull(eptime) = False Then
Application.CurrentDb.Execute ("INSERT INTO TBLANAMPSICHIATRICA
(ID,EPYEAR,EPHOSPITAL,EPTIME) VALUES('" & Me.id & "'," & Epyear & "," &
ephospital & "," & eptime & ")")
End if
Eptime should be filled with data ONLY if the checkbox has been checked, so
it is possible that it has to be left blank and the checkbox unchecked.
But in this case I’m not able to have the SQL line working.
It seems that I HAVE TO provide a number for Eptime: it doesn’t allow for
Null.
Many books say that if a column is mentioned in the INSERT INTO statement
than a value HAVE TO be provided for each column. If there’s no values than
Null should be used. But my statement will pass a Null (since the control has
been left blank).
And this happen only with fields in the table that expect number datatype.
Sounds like you cannot assign a Null value through SQL to a numeric field.
Please can someone explain this messy thing?
Thanks
Rocco