Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Resolved Question

[Access 2010] Change default formats for data types

Sep 27, 2014 8:54PM PDT

Whenever I import data, the default format for Boolean data types is "-1,0." I know how to subsequently change this format to "Yes/No," but I'd like to change the default setting to "Yes/No." Is this possible?

Thanks in advance.

Discussion is locked

cag8f has chosen the best answer to their question. View answer

Best Answer

- Collapse -
Re: import
Sep 27, 2014 9:13PM PDT

If I create a new table in an Access 2010 .accdb file, and make a Boolean field, the default notation is true/false, which I can change to yes/no or on/off. No mention on "-1/0" at all. With importing, it might depend on where you import from. You didn't tell, so I can't try.

But I don't think you can change the built-in defaults.

Kees

- Collapse -
Importing from CSV
Sep 27, 2014 10:14PM PDT

Thanks for the reply. I'm importing from a CSV file.

- Collapse -
Re: csv-file
Sep 28, 2014 11:05PM PDT

I did a little bit of experiment, and that's the way it works. The import makes the new table, since it's smart enough to recognise the contents of this columns as boolean values it makes a boolean field in the new table and it sets the properties of the boolean field to show as 0 and -1. As you noticed, it's easy to change to another mode of showing.

Of course, this only is relevant if you import to a new table. If you import to an existing tables, the existing properties of all fields are kept. For one time operations, I wouldn't mind so much, for repeating operations you better use an existing table anyhow. So it's a very minor (indeed cosmetic) annoyance you'll have to live with.

Kees

- Collapse -
Answer
In programming parlance
Sep 28, 2014 1:52AM PDT

In programming parlance, there's really no difference between any of these things. Generally 0 means false and any non-zero value means true. So my guess would be that the CSV file you're importing from is using numeric values to indicate the boolean disposition.

Make a copy of the CSV file and then open that copy in Notepad or any other text editor really. Use the Replace All function to find -1 values and then replace that with "Yes" and then repeat the process only with 0/No. Then try importing the modified CSV file and see what happens. Be sure to give it a pretty thorough going over because there's always the chance that your modifications hit something else. You may find you need to go back and do something like search for ",0," and replace that with ",No," so if you had some other field that was say "1000000" you don't wind up with "1NoNoNoNoNoNo" etc. This is why you make the copy. That way you can always delete it and make a new copy until you've worked everything out.

- Collapse -
Thanks
Sep 28, 2014 11:07AM PDT

Thanks for your assistance. My CSV has these values set to "Yes" or "No," yet Access sets these to 0, -1 after import.

- Collapse -
As stated
Sep 28, 2014 10:51PM PDT

As stated, there's functionally no difference between them. You're only offered the different options in Access for cosmetic reasons because they all evaluate to either 0 (false) or non-zero (true). If you wanted to build a query for a database, you could use those values interchangeably if you're trying to search based on a boolean field. Of course it never hurts to be sure, so load the file into Access and then just make three very simple queries where you know what the outcome should be or can easily verify by looking at the table created when importing. Make one query using true/false, one using yes/no, and one using -1/0. All three should return exactly the same results.

If the above works, you can just use yes/no or true false later and it will function exactly the same. You just have a small, purely cosmetic, issue where the data is -1/0 instead of yes/no, but it's still exactly the same.

- Collapse -
Not the point
Sep 29, 2014 12:10AM PDT

Thanks for your help. I understand that they are all functionally the same. But I am teaching teenagers how to use Access for the first time. The book from which they learn uses Access, but in their examples, Boolean fields are displayed as Yes/No. So I'd like Access to display Yes/No for them automatically upon import.

- Collapse -
More to the point?
Sep 29, 2014 12:18AM PDT

One of the fun areas of working with data in general is to not fret so much about this import. That is, what mattered in the past was the REPORT on said data.

I could make the REPORT show Yes/No on the printout, PDF or Web display and the underlying data be 1, 0, true/false or other.

Yes we could write some Access code to add a column that would use the source data to make a Yes/No but only a beginner would do that.
Bob

- Collapse -
Au contraire!
Sep 29, 2014 1:55AM PDT

Au contraire! I'd say that makes it all the more relevant to the point. Here's a perfect opportunity to teach these students how to deal with unexpected situations. In the real world, the data you get will be full of errors and you'll have to be able to clean it up. You might have a database that's very old and has been maintained by multiple people. The first person may have preferred 0/1 for true/false, the next person might have used yes/no, etc. You will rarely have nice clean scrubbed data like you get from textbooks and sometimes even there you'll run into unexpected and/or peculiar behavior between versions. So here's your chance to go beyond the textbook and teach these kinds how to deal with a simple unexpected situation.

Frankly, I'd think any good educator would have seized on this opportunity already, though with the way teachers are made into scapegoats for virtually everything these days and school budgets have cut so deep into the bone they've practically nothing left, I wouldn't blame you if you've developed kind of PTSD.

View this as the opportunity it is, not a problem. The one thing I had to teach myself pretty much all the way through school was critical thinking. All the way through college, the classes were great at giving me the facts, but not so much at teaching me how to use those facts. So here's your chance to help rectify that problem with one group of students. It's not much, granted, but it is what you as an individual can do to help make the world a slightly better place and give this group of students (along with others who may follow) a small edge over everyone else when trying to find a job. If you plan the seed of how to think critically and logically work through and/or around problems that come up, it's something that can be applied to virtually any other area of life.

- Collapse -
Thanks
Sep 29, 2014 2:21AM PDT

I appreciate all the enthusiasm. But really I just asked if something small was possible in Access. You're going off on philosophical tangents regarding how I should be educating our future leaders. I hear what you're saying, and I will take the advice to heart. Thanks for your help.

- Collapse -
Yes it's possible.
Sep 29, 2014 2:41AM PDT

That is, to write a little code to clean it up or read the file and add records exactly like you wish. Some courses are limited to only what menus a software title has. But Access has us open to writing bits of code to fill in where the menus fall short.
Bob

- Collapse -
OK
Sep 29, 2014 8:51AM PDT

OK thanks. If I were to pursue the writing-code route, what would be my next step?

- Collapse -
Example to follow.
Sep 29, 2014 9:34AM PDT
- Collapse -
Thanks
Sep 29, 2014 12:32PM PDT

Thanks. This is good to know, but is probably beyond the scope of my present issue. I'll pursue a separate workaround.