Selasa, 28 Juni 2011

Re: [MS_AccessPros] Three state (Yes, No, blank) controls

 

Hi Gary,

you're welcome :)

you can use VBA to loop through all the tables, then all the fields, check to see if the type is a Yes/No field and if it is, you can use code to change it.

If all that looping and coding sounds daunting, here is an easier way:

use my analyzer on your database.

www.AccessMVP.com/strive4peace/Dictionary

Output the qFields query to Excel. then, in Excel, delete columns you don't want. Filter out rows that are not a yes/no field and then you will have a list :)

If your database uses several dozen yes/no fields, perhaps the structure needs some re-design.

Often, people use checkboxes for things that should go into a related table.

for instance, lets say you are a doctor diagnosing a patient. Instead of fields like HasCough, HasSoreThroat, HasFever, you would have this:

Sympoms
- SymptomID, autonumber, PK
- SymptomName, text

where RECORDS would contain the descriptive stuff, ie:
1, HasCough
2, HasSoreThroat
3, HasFever

PatientSymptoms
- PatSympID, autonumber -- PK
- PatientID, long -- FK to Patients
- SymptomID, long -- FK to Symptoms

~~~

often, instead of a Yes/No field to know if something was sent or received, it is better to use a date field to mark the moment.

~~~
well, maybe these are not issues with your database ... never-the-less, as you convert these fields, ask yourself if a better method exists.

~~~
> "It would have been nicer to know they wanted this at the
> beginning "

it can be frustrating to re-do your work, at least you are not alone. Be glad you have a solution today instead of tomorrow :)

Warm Regards,
Crystal

*
(: have an awesome day :)
*

--- On Tue, 6/28/11, Gary D. Schwartz wrote:

> Looks like Crystal's suggestion and
> the Alan Browne article she
> linked, is going to do the trick.
>
> It would have been nicer to know they wanted this at the
> beginning,
> instead of needing to convert several dozen fields from
> Yes/No to this.
>
> Thanks all,
>
> Gary
>
> At 12:25 PM 6/28/2011, you wrote:
> >Hi Gary,
> >
> >the Yes/No data type is a byte, it only supports 2
> values.  You can
> >make your field an Integer and change the
> DisplayControl to a
> >checkbox using this code:
> >
> >CurrentDb.TableDefs("Table1").Fields("Field1").Properties("DisplayControl")
>
> >= CInt(acCheckBox)
> >
> >Allen Browne has an excellent article on this:
> >
> >Why I stopped using Yes/No fields
> >http://allenbrowne.com/noyesno.html
> >
> >
> >Warm Regards,
> >Crystal
> >
> >www.AccessMVP.com/strive4peace
> >
> >  *
> >    (: have an awesome day :)
> >  *
> >
> >
> >--- On Tue, 6/28/11, Gary D. Schwartz wrote:
> >
> >
> > > Hi:
> > >
> > > I am trying to replicate in an Access form a
> feature found
> > > in other
> > > db software.
> > >
> > > In other software, you can have a check box that
> has three
> > > possible
> > > states: "Yes" or 1, "No" or 0, and blank.
> "Yes.shows as a
> > > check mark,
>
>
> --------------------------------------------------------
> Gary D. Schwartz          Please
> reply to: gary.schwartz@pobox.com
>
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar