Solved

List Box displays "-1/0" instead of Yes/No

Posted on 2009-07-02
8
186 Views
Last Modified: 2013-12-25
I have a "Yes/No" column and I want it to be displayed as such on the list box. But it is being displayed as 0 or -1. I need to fix it. Here is the line that needs to be coded to replace 0 with No and -1 with Yes: TEMP_table_for_view.File

I tried a couple of things but something is not working right. Please help.
Thanks
0
Comment
Question by:gkhotline
  • 5
  • 2
8 Comments
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 300 total points
ID: 24768130
Try this instead:

SELECT IIf(TEMP_table_for_view.File, "Yes", "No") AS YesOrNo
FROM TEMP_table_for_view
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24779177
Hi gkhotline,

Change the row source for the Combo/listbox to -1;Yes;0;No
The row source type to Value List
Columns to 2
& column widths to 0;1

Good Luck!

Gary
0
 

Author Comment

by:gkhotline
ID: 24782339
Patrick,
I tried your code and it did not work. What I am trying to do is when i run the command listed below it sorts the data by a certain field, in this case by [file]. The command works just fine, but i need to format it so that I do not see -1/0, but rather yes/no. Please see the code below and let me knoe how to make it work. I am only concerned with the [File] field.
Thank you in advance.
Dim strSQL As String

    strSQL = "SELECT [Return ID], [Legal Entity from Returns], " & _

        "[State from Returns],[Year from Returns], " & _

        "[Filing Position], [FTI], Format([Apportionment Factor],""0.000000%"") AS Apportionment, [STI], " & _

        "Format (TEMP_table_for_view.[Applicable adjustment],""$#,##0"") AS [Applicable Adjustment ], " & _

        "Format (TEMP_table_for_view.[Change in Tax] ,""$#,##0"") AS [Change in Tax ], [Estimated Effect], [Filing Deadline], [File], " & _

        "[Reason] FROM [TEMP_table_for_view] "

    strSQL = strSQL & "ORDER BY [File] ASC"

Open in new window

0
 

Author Comment

by:gkhotline
ID: 24782365
this code:  IIf([TEMP_table_for_view.File],"Yes","No") AS File works in the Row Source query of the list box, but for some reason it does not work in the code I provided you above. I have no clue why.
Thanks
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24782515
gkhotline,

You're going to have to elaborate further on what you are trying to do, and what you mean when you say
it does not work.

Regards,

Patrick
0
 

Author Comment

by:gkhotline
ID: 24784921
Hi,
Basically I have a "sort" button and when I release (on release) that button the command is being executed in a procedure (see code below). It is sorting the table before it is displayed in the listbox. In this case it is being sorted by [File] column. Currently the sort works perfectly, but it displays "0/-1" and I want it to display "yes/no".  What I mean by "it does not work" - when I click on that button it sends me back to my procedure with an error message, something to the effect "syntax is incorrect". It does not tell me what is the exact problem with my syntax and I know that it is that code that I inputed before, which is:
If I take it out it sorts it ok, but not the way I want it.
I hope that clarifies it a bit.
Thanks
Private Sub Command159_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

    Dim strSQL As String

    strSQL = "SELECT [Return ID], [Legal Entity from Returns], " & _

        "[State from Returns],[Year from Returns], " & _

        "[Filing Position], [FTI], Format([Apportionment Factor],""0.000000%"") AS Apportionment, [STI], " & _

        "Format (TEMP_table_for_view.[Applicable adjustment],""$#,##0"") AS [Applicable Adjustment ], " & _

        "Format (TEMP_table_for_view.[Change in Tax] ,""$#,##0"") AS [Change in Tax ], [Estimated Effect], [Filing Deadline], IIf(TEMP_table_for_view.[File],"Yes","No") AS [Files], " & _

        "[Reason] FROM [TEMP_table_for_view] "

    strSQL = strSQL & "ORDER BY [File] ASC"

Open in new window

0
 

Author Comment

by:gkhotline
ID: 24784941
Forgot the code that i used: IIf(TEMP_table_for_view.[File],"Yes","No") AS [Files]
0
 

Accepted Solution

by:
gkhotline earned 0 total points
ID: 24785016
Never mind..I just resolved it. "yes" and "no" had to be double quoted as such: IIf(TEMP_table_for_view.[File],""Yes"",""No"") AS [Files]
Thank you for your help!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now