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

Boolean Fields and MicroSucks! 1

Status
Not open for further replies.

beruken

Programmer
Mar 12, 2002
22
0
0
US
I have an Access 2000 database that has a field set to Yes/No and formatted as true/False. Nothing, I say nothing works when I try to read the fields value. i.e

Dim oRst, sQuery
Set oRst = Server.CreateObject("ADODB.Recordset")
sQuery = "Select * FROM tblPOW WHERE tblPOW.Current = -1"
oRst.Open sQuery, oConn,adOpenStatic,adLockReadOnly

I have tried every combination possible. True, -1, 0 False, Yes, No. Still I get the following error.

error '80004005'
Unspecified error

This is such a basic and simple little query why wont it work? I do have no problem updating the field as true or false though.

For 3 Friggin years I have never gotten this field type to behave as it should or was intended by MicroSUCKS!

 
It is possible that the "Current" field is a reserved word. Try enclosing the name of the field in brackets as follows:

sQuery = "Select * FROM tblPOW WHERE tblPOW.[Current] = -1"

Also, I think you are correctly using the Boolean literals, -1, 0, True, and False. I'm not certain about Yes and No however. Another option is as follows:

sQuery = "Select * FROM tblPOW WHERE tblPOW.[Current]"

Because the WHERE clause is after a boolean, you don't actually have to compare the "Current" field to any boolean literal. The boolean field returns the selection criteria all by itself!

The only other concern that I have is that the oConn variable refers to an open connection in the statement:

oRst.Open sQuery, oConn,adOpenStatic,adLockReadOnly
 
The problem might be that the checkbox(I assume that this is a checkbox on the form) is defaulted to Null unless otherwise specified for new record or in an unbound form. I always give a default value to the checkbox, that way it its either true or false and not Null.


Just thought I'd add my two cents.

Bob [flip]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top