Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-07-02
8
Medium Priority
?
237 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 93

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 1200 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

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 93

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

670 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