Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2000. Error '2113' when set CheckBox to the CheckBox.OldValue

Status
Not open for further replies.

andreymurom

Programmer
May 18, 2001
10
US
I had this code in Before_Update procedure:

If .....
Me![chkXXX] = Me![chkXXX].OldValue
End If

If I try to enter a new record and don't touch this check Box and then move to another record, I am getting "Run-time Error '2113'. The value you entered isn't valid for this field".

I could work around this problem by changing the code to:

If .....
If Me![chkXXX].OldValue = True Then
Me![chkXXX] = True
Else
Me![chkXXX] = False
End If
End If

So it looks like something is wrong with the data type or data format that .OldValue returns.

I looked at the help and OldValue is of variant data type and returns the same data type that it is getting, including Boolean. I tried to change data format in the table field that populates that check box from Yes/No to True/False but result is the same.

Can anybody suggest me what is going on and what the proper way to fix the problem would be?

Thank you very much,

Andre
 
Hi Andre!

If no value has been selected for the check box, then your old value property will return a null. You cannot set a check box to a null value, even though that is where they start. So, you have a couple of options:

1.) Check for a null value in old value and only run the code if it isn't null.

2.) Set the triple state propert of the check box to yes, then it will accept a null value.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Thank you very much Jeff, I did not know about Null, I thought it would be whatever Default Value I choose in the check box properties. Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top