Rabu, 29 Agustus 2012

Re: [MS_AccessPros] Change 0 or -1 value to Yes or No format

 

Hi Phucon,

>            If Me.IsSupervisor.Value = -1 Then
>                Me!txtIsSupervisor.Value = "Yes"
>            Else
>                If Me.IsSupervisor = 0 Then
>                    Me!txtIsSupervisor.Value = "No"
>                End If

as John said, "Yes/No" can be displayed using a textbox with format property set to --> Yes/No
"Yes" and "No" are both text and, therefore, will be 0, which is False when converted to a number

> "Why I stopped using Yes/No fields" in Allen Brown's MS Access Tips,
then I switch, and tried to learn another technique... defined the field as
Number data type instead of Yes/No. 
>What interesting me was, even the value of the field was entered as -1, when I
output them to the immediate window they are all become 0(s).

If you want checkboxes to show up in the table when you look at the datasheet view, copy this to the immediate window (Ctl-G), make the changes to Tablename and fieldname, then press ENTER while on the line to execute it

CurrentDb.TableDefs("Tablename").Fields("Fieldname").Properties("DisplayControl") = CInt(acCheckBox)

WHERE
Tablename is the Name of your table
Fieldname is the Name of a field that is a number where you want the display control to change to checkbox

here is a link to Allen Browne's article:

Why I stopped using Yes/No fields
http://allenbrowne.com/noyesno.html

~~~

alternately, you can simply use a checkbox on the form instead of a textbox ... whatever looks best :)

Warm Regards,
Crystal

 *
   (: have an awesome day :)
 *

________________________________
From: John Viescas <JohnV@msn.com>
To: MS_Access_Professionals@yahoogroups.com
Sent: Wednesday, August 29, 2012 9:52 AM
Subject: RE: [MS_AccessPros] Change 0 or -1 value to Yes or No format

Phucon-

You're not listening to me.  The field can be a number data type, but if you set
the FORMAT of the control to Yes/No, it will display as you want it to.

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of saigonf7q5
Sent: Wednesday, August 29, 2012 5:14 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] Change 0 or -1 value to Yes or No format

Good morning Mr.Viescas

I did start with Yes/No fields form the beginning. The story was I read the
article "Why I stopped using Yes/No fields" in Allen Brown's MS Access Tips,
then I switch, and tried to learn another technique... defined the field as
Number data type instead of Yes/No.

What interesting me was, even the value of the field was entered as -1, when I
output them to the immediate window they are all become 0(s).

--- In MS_Access_Professionals@yahoogroups.com, John Viescas <JohnV@...> wrote:
>
> Phucon-
>
> You don't need the textbox or the code.  Simply set the Format of the control
> displaying the number field to "Yes/No".  Why didn't you use a Yes/No data
type?
>
> John Viescas, author
> Microsoft Office Access 2010 Inside Out
> Microsoft Office Access 2007 Inside Out
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
>
>
>
> -----Original Message-----
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of saigonf7q5
> Sent: Tuesday, August 28, 2012 8:14 PM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: [MS_AccessPros] Change 0 or -1 value to Yes or No format
>
> One of the field of my table was set as NUMBER data type. The value of the
field
> is either 0 or -1 to simulate  a Yes/No field.
>
> When this field was displayed in a form, it shows 0 or -1.  I added a textbox
> next to it and try to display "Yes" or "No" instead of showing 0 and 1 by
> creating a procedure as shown below.  However the value's never become True,
it
> always displays 0 or No. What's wrong with that?
>
> Private Sub Form_Open(Cancel As Integer)
> Set rs = CurrentDb.OpenRecordset("StaffInfo", dbOpenSnapshot)
> With rs
>    If Not .EOF Then
>        .Movefirst
>        Do
>            Debug.Print Me.IsSupervisor
>              .MoveNext
>            If Me.IsSupervisor.Value = -1 Then
>                Me!txtIsSupervisor.Value = "Yes"
>            Else
>                If Me.IsSupervisor = 0 Then
>                    Me!txtIsSupervisor.Value = "No"
>                End If
>            End If
>        Loop Until .EOF
>    End If
> End With
> End Sub
>
> Phucon
>
>

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar