Solved

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

Posted on 2009-07-02
8
176 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
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.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

708 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

15 Experts available now in Live!

Get 1:1 Help Now