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!

Boolean values in Access DB trouble.

Status
Not open for further replies.

HighlandJinx

Programmer
May 20, 2002
34
GB
Hi folks, i'm having trouble with VB6 and accesss. I create a new table in VB6 using SQL, into an already created Access DB. All the values in the table are boolean and has no indexing as it is a look-up table, the problem is that I need the boolean values to be formatted to TRUE/FALSE and not 0/-1 as is set when creating the table in SQL. Can anyone tell me how to format the Access tables values using SQL in VB6?

Thanks a lot folks.
 
True is stored as -1 and False is stored as 0. You can display how you want. The CBool function will return False for 0 values and True for other numeric values

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
The problem i'm having is that a table that has it's Yes/No typedata set to True/False in access, when i create a table at run-time can i set the tables format to Yes/No using VB, it's for an updater we send to clients to bring their DB structure up to date with ours. It's essencial that the access recognises the format as beinf True/False.

Thanks for your time.
 
johnwm is correct about what is stored. I don't think you can alter the format through SQL, but you can alter this property through DAO. Here "db" is your DAO database object.

[tt]db.tabledefs("yourtable").fields("youryesno").properties("format")="Yes/No"[/tt]

Available, I think is "Yes/No", "True/False", "On/Off"

Should you be needing to alter which "control type" is displayed for the field too, it's the "DisplayControl" property, and available settings are 106 - acCheckBox, 109 - acTextBox, - 111 - acComboBox (Access constants).

I'm not sure, but I don't think you can alter this property of Access field through ADO.

But as johnwm points out, this is only about how the field value is displayed when opening the table, it stores -1 for true 0 for false anyway...

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top