Solved

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

Posted on 2009-07-02
8
193 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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
 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 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