G
Guest
I am adding records to a table with the following code. Initially, the
comments field is automatically populated with the current date. I use the
"If" statement to see if the user has entered anything to the comments field
after the date.
If the user doesn't add anything after the date, I want to remove the date
and not add anything to the comments field in the table. I tried to remove
the existing data in the comments field but I get a 3315 err when it tries to
add the record to the table.
I have been able to get around it by adding a space to the comments field
but I really don't want to have the space in the comments field on the table
because I'll have to deal with that space later.
Comm = Forms![Form1]![Comments].Value
Comm1 = (Len(Comm) - 1)
If Mid(Comm, Comm1, 1) = "-" Then
Forms![Add Unit]![Comments Field].Value = " "
End If
On Error GoTo DoLineError
CurrentDb.Execute "INSERT INTO [Unit Table]([Stock Num], [EmployeeID],
[Date],[Comments]) VALUES('" & Me.SN_Field & "','" & Me.EmployeeID_Field &
"',#" & Me.Date_Field & "#, '" & Me.Comments_Field & "')", dbFailOnError
Any suggestions on how to add the record without anything in the comments
field would be appreciated. Thanks for the help.......
comments field is automatically populated with the current date. I use the
"If" statement to see if the user has entered anything to the comments field
after the date.
If the user doesn't add anything after the date, I want to remove the date
and not add anything to the comments field in the table. I tried to remove
the existing data in the comments field but I get a 3315 err when it tries to
add the record to the table.
I have been able to get around it by adding a space to the comments field
but I really don't want to have the space in the comments field on the table
because I'll have to deal with that space later.
Comm = Forms![Form1]![Comments].Value
Comm1 = (Len(Comm) - 1)
If Mid(Comm, Comm1, 1) = "-" Then
Forms![Add Unit]![Comments Field].Value = " "
End If
On Error GoTo DoLineError
CurrentDb.Execute "INSERT INTO [Unit Table]([Stock Num], [EmployeeID],
[Date],[Comments]) VALUES('" & Me.SN_Field & "','" & Me.EmployeeID_Field &
"',#" & Me.Date_Field & "#, '" & Me.Comments_Field & "')", dbFailOnError
Any suggestions on how to add the record without anything in the comments
field would be appreciated. Thanks for the help.......