Not able to set date field to Null value

Romio68

Registered User.
Local time
Today, 23:41
Joined
Sep 4, 2013
Messages
27
I have a form that runs a search query.
I have an error trap set on a date field.

If (DataErr = 2113) Then
Select Case Screen.ActiveControl.Name
Case "DA_Start"
MsgBox "invalid date", vbExclamation
Me.DA_Start. = Null
End Select
Response = acDataErrContinue
End If
End Sub

This will pop up the error message, but wil trigger the debuger when gettin to "Me.DA_Start = Null"

And I really don't understand why...
 
Is that a period at the end or Me.DA_Start? If so you'll want to remove it...

Code:
Me.DA_Start. = Null

If that doesn't clear it up, try...

Code:
Me.DA_Start = ""
 
Last edited:
Doesn't work...
I tried

Me.DA_Start = Null
Me.Da_Start = ""
Me.Da_Start.Value = Me.Da_Start.DefaultValue (it has the default set to #01-01-2000#
Me.Da_Start.Value = #01-01-2000#

It seemns that i cannot set anything trough VBA. Only from keyboard...
:banghead:

Whole story now
The form searches trough data in a table, using a select query, and will display results in a subform.
It has many field, to narrow the search results (all working, including DA_Start)
when typing a date inside DA_Start, will triger an "On Enter"
Me.Form.Refresh (working too), in order to narow the result imediately after a field is filled.
After having all working, I started to look over the error protection.

I set an input mask on DA_Start, and narrowed the key usege trough an On KeyDown Event. (all is doing well)

On the form itself, I tried to set an error handler with the code above.
If i do not add on the error handler that part with changing the field value, the handler works ok, and will not allow the user to leave the cell until a proper value is inserted.

But I want in the case that user entere a date like 99-99-9999, a message to be displayed and the value to be modified tu Null or to the default vale as well...

And between what I want and what I gat, stays a Runtime error 2147352567 (80020009)


 
Is there a Default Value in the Properties window of that field?
 
Yes.

Default value set in field properties to #01-01-2000#

Format set in field properties to dd-mm-yyyy

input mask set on form Onload event for all date fields: Me.DA_Start.InputMask = "00-00-0000;0;*"

Code above set on form OnError event

OnEnter field event: Me.Form.Refresh set

OnKeyDown field event set to check for invalid chars
 
Nothing ...
And I really need that default value, anyway. But I give it a try...
 
If it works then we know *why* it's happening...
 
It doesn't ...
I did the change and nothing comes out of it
 
Running out of ideas here. So let's try...

Commenting this out...

'Me.DA_Start = Null

Do you get the error message?
 
Me.DA_Start = Null

The custom message is throwed and then:
Runtime error 2147352567 (80020009) on the " Me.DA_Start = Null " line
 
Runtime error 2147352567 is "You cannot assign value to this field" ... so either the recordset has turned not updateable or the timing is wrong ( at some times you cannot change the value of a field).

Try


Me.DA_Start.Undo
 
spikepl you may have called it... It's a timing issue because you can manually type in that field.

Romio68... You should not have gotten an error on a line that is commented out UNLESS it is also somewhere else in the code?
 

Users who are viewing this thread

Back
Top Bottom