Solved

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

Posted on 2009-07-02
8
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

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)

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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.
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 …

738 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