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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox error

Status
Not open for further replies.

pcpro

MIS
Feb 24, 2001
15
US
I am trying to use a checkbox in my form connected to a access 97 database using ADO.

It works until I have a record that has the box checked. Then I get run-time error '380' Invalid Property Value.

Code:
chk_Equipment = !Equipment

I have tried:
chk_Equipment = !Equipment & " "
chk_Equipment = !Equipment & -1
chk_Equipment = !Equipment & "-1"
chk_Equipment = !Equipment & 0
chk_Equipment = !Equipment & "0"
chk_Equipment = !Equipment & Yes
chk_Equipment = !Equipment & "Yes"
But I get run-time error type mismatch.

The format in access for the checkbox is Yes/No. No is default.

Any Suggestions?
 
pcpro -

VB checkboxes have three potential values - checked, unchecked, and grayed-out. You should use the correct constant to check for each condition. Also, the exclamation-mark operator is going away in ADO.NET, so you might want to get accustomed to using the Fields collection. Default properties are going away too, so it might be good to start specifying the correct property as well.

[tt]
chk_Equipment.Value = IIf(adoRS.Fields("Equipment").Value, vbChecked, vbUnchecked)
[/tt]

Chip H.

BTW. Unless your database doesn't allow a null for column "Equipment", you should check for a null condition with the IsNull() function.

 
Thanks RAtkison the code worked...

Chiph I did not try yours but I am sure it would have worked also..

Thanks for the help Guys..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top