Solved

MS Access form Listbox displaying 0/-1 instead of Yes/No

Posted on 2008-06-13
14
217 Views
Last Modified: 2013-12-25
Hello,

I have a peculiar problem.
Its related to MS Access 2003 and the .mdb file resides in a server.
I have a form which contains a list box and the list box is bound to a query. The query fetches records from tables. Two columns represents Yes/No field in the table.
When the application is run, two columns (out of several other columns) should display Yes/No.

The problem is, on some machines the list box column showing Yes/No and in some machines its displaying 0/-1.

Why is this unusual behavior?
0
Comment
Question by:venkeykanle
  • 3
  • 3
  • 3
  • +2
14 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 42 total points
ID: 21781503
>When the application is run, two columns (out of several other columns) should display Yes/No.
Yes/No values are ultimately stored as -1 or 0 in tables.

Instead of your query having ColumnName1, ColumnName2, use ...
iif(ColumnName1=-1, "Yes", "No") as Column1, iif(ColumnName2=-1, "Yes", "No") as Column2

Then it will display as Yes or No in your list box.
0
 
LVL 44

Assisted Solution

by:GRayL
GRayL earned 42 total points
ID: 21782114
Change the query behind listbox1 to:

Select yn1, Format(yn1,"Yes/No") from myQuery;

Bound coumns 1
Number of columns2
Column Widths 0;.5"

this will produce the correct Yes/No string for the corresponding value of -1 or 0 in the field yn1
0
 

Author Comment

by:venkeykanle
ID: 21782131
If I directly run the query I get yes/no fields, because field data type is Yes/No.
As i mentioned some system produce Yes/No and some other 0/-1 !!!!
I could not figure out; may be some system settings would have caused so?
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 21782153
>may be some system settings would have caused so?
In Table Design, click on your Yes/No fields, then in the lower left of your screen eyeball what's in the Format property.
0
 

Author Comment

by:venkeykanle
ID: 21782216
Field format is also Yes/No.
Another thing is that it was working fine for quite a long time. Recently it started giving problem (again not on all systems). Anything do with Access version/patch?
0
 
LVL 44

Expert Comment

by:GRayL
ID: 21782288
Probably, I had several inexplicable behavior changes recently to the point where I turned the auto updates off and now get the system to advise updates are ready to be installed.  I then get a chance to read up on what the update is about.  I'm still a bit confused.  Are you saying the results of your query display yes/no on some machines and others display -1,0?  You don't get both combinations in the same recordset?  In that case, displaying the Yes or No and storing the actual data as I showed you will cover all the bases.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 44

Expert Comment

by:GRayL
ID: 21782362
Did a bit more checking in the design view of the table and found you can set a number to integer or long, and set the format to Yes/No in the sub pane.  Similarly you can use True/False.
0
 
LVL 33

Expert Comment

by:Mike Eghtebas
ID: 21783249
As it is has been mentioned before.

In the design view of the table select YEsNo field and then at the bottom, select Lookup. at "Display Control" select Cpmbo Box to have it displayed as Yes/No.

Mike
0
 
LVL 33

Expert Comment

by:Mike Eghtebas
ID: 21783272
BTW, you may have to clear the combo box row source and start its row source again in case the field formats might have been copied to the row source differntly.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 21784941
Yes/No = True/False = -1/0

On the form:Format Yes/No displays Yes/No
                             True/False displays  True/False
                           
<showing Yes/No and in some machines its displaying 0/-1.>
Compare the format of the text box on both machines.
0
 

Assisted Solution

by:venkeykanle
venkeykanle earned 41 total points
ID: 21838146
Hi all,
Sorry for the delay; held up doing some other assignment.
Any way, I got the solution.
The problem lies with the MS Access 2003 version. Access with 2003 SP3 has this issue (refer
http://support.microsoft.com/kb/945280). With SP3 'Yes/No' would display as '-1/0' (in listbox or combo)and this should be removed in query (record source for listbox or combo). Where as earlier version this works fine.

Thanks everybody who responded quickly.
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 21838896
I object to the deletion.  Many excellent work-arounds were posted here.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

758 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

21 Experts available now in Live!

Get 1:1 Help Now