Null Value

B

Beeyen

Good Day,

I have a checkbox with the coding notice below. What is happening is the
date is populating the field through the checkbox. When you select the
checkbox the date is enter into a field next to the checkbox, if you deselect
the checkbox the date is removed from the same field next to the checkbox.
Before this all occurs when you first select the checkbox a dialog box with
"You tried to assign the Null value to a variable that is not a Variant data
type". Once you click on 'OK' the message goes away and the check enter in
the box and the date showns in the field. Could someone explain why this is
happening and assist me with the prevention of the error message?

Thank you in advance

Private Sub ASSIGNEDCHECKBOX_AfterUpdate()
If Me.ASSIGNEDCHECKBOX.Value = True Then
Me.[Assigned Date/Time] = Now() ' or now() for date/time
Else
Me.[Assigned Date/Time] = Null

End If

End Sub
 
D

Dirk Goldgar

Beeyen said:
Good Day,

I have a checkbox with the coding notice below. What is happening is the
date is populating the field through the checkbox. When you select the
checkbox the date is enter into a field next to the checkbox, if you
deselect
the checkbox the date is removed from the same field next to the checkbox.
Before this all occurs when you first select the checkbox a dialog box
with
"You tried to assign the Null value to a variable that is not a Variant
data
type". Once you click on 'OK' the message goes away and the check enter
in
the box and the date showns in the field. Could someone explain why this
is
happening and assist me with the prevention of the error message?

Thank you in advance

Private Sub ASSIGNEDCHECKBOX_AfterUpdate()
If Me.ASSIGNEDCHECKBOX.Value = True Then
Me.[Assigned Date/Time] = Now() ' or now() for date/time
Else
Me.[Assigned Date/Time] = Null

End If

End Sub


Is "Assigned Date/Time" the name of a field in your form's recordsource? If
so, it's not a good name, but I can't see why this code would be causing the
error you report. Is there any other code (or macros) in other events of
the check box or the surrounding controls -- maybe the check box's Enter or
GotFocus event?
 
B

Beeyen

I got it! I changed the Assigned Date/Time in the table to Assigned DateTime.

Thanks

Dirk Goldgar said:
Beeyen said:
Good Day,

I have a checkbox with the coding notice below. What is happening is the
date is populating the field through the checkbox. When you select the
checkbox the date is enter into a field next to the checkbox, if you
deselect
the checkbox the date is removed from the same field next to the checkbox.
Before this all occurs when you first select the checkbox a dialog box
with
"You tried to assign the Null value to a variable that is not a Variant
data
type". Once you click on 'OK' the message goes away and the check enter
in
the box and the date showns in the field. Could someone explain why this
is
happening and assist me with the prevention of the error message?

Thank you in advance

Private Sub ASSIGNEDCHECKBOX_AfterUpdate()
If Me.ASSIGNEDCHECKBOX.Value = True Then
Me.[Assigned Date/Time] = Now() ' or now() for date/time
Else
Me.[Assigned Date/Time] = Null

End If

End Sub


Is "Assigned Date/Time" the name of a field in your form's recordsource? If
so, it's not a good name, but I can't see why this code would be causing the
error you report. Is there any other code (or macros) in other events of
the check box or the surrounding controls -- maybe the check box's Enter or
GotFocus event?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
K

Keith Wilby

Beeyen said:
I got it! I changed the Assigned Date/Time in the table to Assigned
DateTime.

Generally, "special" characters such as slashes, spaces etc are considered
to be a bad thing in field names. You can give your fields abbreviated
names, eg "AssDateTime" and make the field's *caption* more
end-user-friendly, eg "Assigned Date/Time".

Keith.
www.keithwilby.co.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top