Checkbox error

B

Beeyen

Good Day,

I am trying to have a checkbox to enter the date and time [Now ()] into a
field and if the box is not check then it remains blank. The coding I have
place in the After Update is noted below, but when I check the box I receive
“You tried to assign the Null value to a variable that is not a variant data
typeâ€. I click “Okâ€, a check appears in the checkbox along with the date and
time. When I try to deselect the checkbox I receive the VB error box –
Runtime error ‘2164’
You can’t disable a control while it has the focus.

Can anyone assist?

Private Sub ASSIGNEDCHECKBOX_AfterUpdate()
If Me.[ASSIGNEDCHECKBOX] = True Then
Me.[Assigned Date/Time] = Now()
Else
Me.[ASSIGNEDCHECKBOX].Enabled = False

End If
End Sub
 
T

Tom van Stiphout

On Mon, 13 Apr 2009 06:13:02 -0700, Beeyen

Disabling the checkbox seems a bad idea: how would the user be able to
change her mind? If you must, first set focus somewhere else
(SetFocus), then disable it.
The null value error I don't understand.

-Tom.
Microsoft Access MVP
 
B

Beeyen

Good Day Mr. Tom Stiphout,

I have managed to get the checkbox to work with the coding below, that is, I
check the box it enters the current date, I deselect the box it removes the
date. However, upon selecting the checkbox, I continue to receive the “You
tried to assign the Null value to a variable that is not a variant data
typeâ€. I select “Okâ€, a check appears in the checkbox along with the date
and time. I deselect the box and the field blank as wanted. I’m at a lost.

Any ideas?

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



Tom van Stiphout said:
On Mon, 13 Apr 2009 06:13:02 -0700, Beeyen

Disabling the checkbox seems a bad idea: how would the user be able to
change her mind? If you must, first set focus somewhere else
(SetFocus), then disable it.
The null value error I don't understand.

-Tom.
Microsoft Access MVP

Good Day,

I am trying to have a checkbox to enter the date and time [Now ()] into a
field and if the box is not check then it remains blank. The coding I have
place in the After Update is noted below, but when I check the box I receive
“You tried to assign the Null value to a variable that is not a variant data
typeâ€. I click “Okâ€, a check appears in the checkbox along with the date and
time. When I try to deselect the checkbox I receive the VB error box –
Runtime error ‘2164’
You can’t disable a control while it has the focus.

Can anyone assist?

Private Sub ASSIGNEDCHECKBOX_AfterUpdate()
If Me.[ASSIGNEDCHECKBOX] = True Then
Me.[Assigned Date/Time] = Now()
Else
Me.[ASSIGNEDCHECKBOX].Enabled = False

End If
End Sub
 
T

Tom van Stiphout

On Mon, 13 Apr 2009 09:17:01 -0700, Beeyen

When that error occurs, hit Ctrl+Break and hopefully you'll be on a
line of VBA code other than the ones you are posting here.

[Assigned Date/Time] is a nullable field in the underlying table,
right?

-Tom.
Microsoft Access MVP

Good Day Mr. Tom Stiphout,

I have managed to get the checkbox to work with the coding below, that is, I
check the box it enters the current date, I deselect the box it removes the
date. However, upon selecting the checkbox, I continue to receive the “You
tried to assign the Null value to a variable that is not a variant data
type”. I select “Ok”, a check appears in the checkbox along with the date
and time. I deselect the box and the field blank as wanted. I’m at a lost.

Any ideas?

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



Tom van Stiphout said:
On Mon, 13 Apr 2009 06:13:02 -0700, Beeyen

Disabling the checkbox seems a bad idea: how would the user be able to
change her mind? If you must, first set focus somewhere else
(SetFocus), then disable it.
The null value error I don't understand.

-Tom.
Microsoft Access MVP

Good Day,

I am trying to have a checkbox to enter the date and time [Now ()] into a
field and if the box is not check then it remains blank. The coding I have
place in the After Update is noted below, but when I check the box I receive
“You tried to assign the Null value to a variable that is not a variant data
type”. I click “Ok”, a check appears in the checkbox along with the date and
time. When I try to deselect the checkbox I receive the VB error box –
Runtime error ‘2164’
You can’t disable a control while it has the focus.

Can anyone assist?

Private Sub ASSIGNEDCHECKBOX_AfterUpdate()
If Me.[ASSIGNEDCHECKBOX] = True Then
Me.[Assigned Date/Time] = Now()
Else
Me.[ASSIGNEDCHECKBOX].Enabled = False

End If
End Sub
 
B

Beeyen

Thanks for responding and your patience! I changed the field name Assigned
Date/time to Assigned DateTime in the Design Table and it worked.

Tom van Stiphout said:
On Mon, 13 Apr 2009 09:17:01 -0700, Beeyen

When that error occurs, hit Ctrl+Break and hopefully you'll be on a
line of VBA code other than the ones you are posting here.

[Assigned Date/Time] is a nullable field in the underlying table,
right?

-Tom.
Microsoft Access MVP

Good Day Mr. Tom Stiphout,

I have managed to get the checkbox to work with the coding below, that is, I
check the box it enters the current date, I deselect the box it removes the
date. However, upon selecting the checkbox, I continue to receive the “You
tried to assign the Null value to a variable that is not a variant data
typeâ€. I select “Okâ€, a check appears in the checkbox along with the date
and time. I deselect the box and the field blank as wanted. I’m at a lost.

Any ideas?

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



Tom van Stiphout said:
On Mon, 13 Apr 2009 06:13:02 -0700, Beeyen

Disabling the checkbox seems a bad idea: how would the user be able to
change her mind? If you must, first set focus somewhere else
(SetFocus), then disable it.
The null value error I don't understand.

-Tom.
Microsoft Access MVP


Good Day,

I am trying to have a checkbox to enter the date and time [Now ()] into a
field and if the box is not check then it remains blank. The coding I have
place in the After Update is noted below, but when I check the box I receive
“You tried to assign the Null value to a variable that is not a variant data
typeâ€. I click “Okâ€, a check appears in the checkbox along with the date and
time. When I try to deselect the checkbox I receive the VB error box –
Runtime error ‘2164’
You can’t disable a control while it has the focus.

Can anyone assist?

Private Sub ASSIGNEDCHECKBOX_AfterUpdate()
If Me.[ASSIGNEDCHECKBOX] = True Then
Me.[Assigned Date/Time] = Now()
Else
Me.[ASSIGNEDCHECKBOX].Enabled = False

End If
End Sub
 

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