473,385 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Combo Box doesn't show selection. Why?

675 512MB
Access 2003 Windows XP
I have a combo box on a my form fOptions named cboSortOrder
Relevant properties are:
Name: cboSortOrder
Row Source Type: = Value List
Row Source : "";"Ascending","ORDER BY DESC","Descending"
Bound Column : 1
Column Count: 2
Column Widths: 0";2"

I intended to write code such as:
Expand|Select|Wrap|Line Numbers
  1. sqlShow = sqlSELECT & sqlFROM & sqlWHERE & [cboSortOrder] & ";"
If I choose 'Descending' in my combo box, then the combo box displays 'Descending' and in the Immediate Pane ?Forms!fOptions.cboSortOrder is: ORDER BY DESC
But if I choose 'Ascending', then the combo box displays a blank/empty and ?Forms!fOptions.cboSortOrder is: Null

Why is this result Null? It is clearly set to a zero-length string in Row Source and a zero-length string is not Null.
Why doesn't the word 'Ascending' appear in the combo box when selected?

I am NOT looking for a fix, but for understanding. I can work around this. In the above example, replacing "" with " " in Row Source makes everything work as expected, with the current Jet Engine. Other places not so simple, but I can use numeric values in column 1 (Bound) and If ... then ... else statements to build my SQL Statements.

I was trying to simplify my code, but I don't like to rely on other programs (Jet) to work correctly in the future with non-perfect data.
Sep 20 '10 #1
9 5615
Mariostg
332 100+
Your problem has to do with the column count. Try 1 instead...
Sep 20 '10 #2
Stewart Ross
2,545 Expert Mod 2GB
Hi OB. The syntax for what you want to do with the combo's value is slightly out, in that the ORDER BY clause in SQL should be

ORDER BY [YourFieldName]
or
ORDER BY [YourFieldName] ASC (the ASC tag is assumed if left off)
or
ORDER BY [YourFieldName] DESC

If you wish to construct a SQL string using the combo's value to select the sort order you'll need to specify the field you are ordering on as part of the ORDER BY clause.

-Stewart
Sep 20 '10 #3
OldBirdman
675 512MB
For properties, columns are referred to as one-based, so 2 columns is correct. If referencing in VBA code, then columns are zero-based, and so I would have column(0) and column(1).
Sep 20 '10 #4
Mariostg
332 100+
Then what you want is:
Expand|Select|Wrap|Line Numbers
  1. Row Source : "ORDER BY ASC";"Ascending","ORDER BY DESC","Descending"
  2.  
Sep 20 '10 #5
OldBirdman
675 512MB
Stewart -
You're correct, I forgot the field name in the ORDER BY clause in my example. This was my error in moving the essence of the problem from a database of 20MB size to this forum.

Mariostg -
In my original post, I ask:
Expand|Select|Wrap|Line Numbers
  1. Why is this result Null? It is clearly set to a zero-length string in Row Source and a zero-length string is not Null.
  2. Why doesn't the word 'Ascending' appear in the combo box when selected?
There are many work-arounds for this example, fewer if this is a WHERE clause instead of an ORDER BY.
If one of my choices is a zero-length string, for whatever reason of logic of my program, why can't I have that in a combo box?
Sep 20 '10 #6
Mariostg
332 100+
OldBridMan,
If I understand correctly, if you select Descending, you want to build a clause that has "Order By Desc" in it. While if you select Ascending, you don't do anything special with the clause as far as ordering goes. But yet when you select Ascending, you see a blank as opposed to see Ascending.
I tried it and although I cannot explain why, if you put a space between your empty double quotes, it works fine i.e. the word Ascending will appear in the selection.
Sep 20 '10 #7
OldBirdman
675 512MB
Let me try again. I don't care about the SQL string. My question is about the combo box. I only included the SQL to show what I was doing with the combo box. My original post says:
Expand|Select|Wrap|Line Numbers
  1. I am NOT looking for a fix, but for understanding. I can work around this.
So OK, new example. I want a combo box that has the numbers 0 through 9, and when I select one of these numbers, I want the combo box to have as its value a string with the length selected, filled with the number selected. Select 2 and the combo box would have as its value "22". Select 8 and result would be "88888888". I'm not going to say why I want this, because I don't want a fix. I want to know why a Row Source of
Expand|Select|Wrap|Line Numbers
  1. "";"0";"1";"1";"22";"2";"333";"3"";"4444";"4"";"55555";"5"";"666666";"6"";"7777777";"7"";"88888888";"8";"999999999";"9"
doesn't work, if all other properties are as stated in my original post.
Doesn't work how? If I select 1, 2, ... thru 9, it works. The number is displayed in the combo box, and its value is a string. If I select 0, the combo box appears empty, as if nothing is selected. The combo box's value is Null, not the zero-length string "".
My question then is: How can I have a zero-length string as a value for a combo box?
Sep 20 '10 #8
Stewart Ross
2,545 Expert Mod 2GB
Short answer is that you cannot return an empty string from a value list. The null value returned reflects the absence of a value between the delimiters in the list element concerned. I would speculate that the developers did not have in mind empty strings as possible values in a value list.

To accomplish what you want you can use the Nz function on the value of the combo. This will return an empty string in place of the null when that row is selected, leaving the other value list entries that are non-null unaffected:

SomeValue = Nz(YourCombo)

Re your comment on the SQL part not being the point of your question, we'd not be helping other posters who might be taking different things than you expect from reading your question if we did not point out that the ordering example given would not quite work as posted. I accept that it was not the point of your question, however.

-Stewart
Sep 20 '10 #9
OldBirdman
675 512MB
Curiouser and curiouser. Short answer is "I can't", but what is going on?
If I change to a table (2 rows, 2 fields) with the same data as the value list, the combo box can have a zero-length string. This is different from a Value List, which cannot put a "" into the .Value property. Choosing a row with a zero-length string results in the displayed text (text box portion of combo box) being set to a zero-length string.
The rows and columns of the combo box have the correct values, with .Column(0,0) being "" even after Access puts a null in the combo's .Value property. I can find no difference at run-time with the row/column of the combo box whether it is from a Table or a Value List.
When a row is selected, Access should assign the .Value property whatever is in the bound column for that row. The display is the .Text property, and that should be assigned from the column shown.
The fact that .Text is set to "" when .Value = "" is weird. Is Accessing testing for this condition and messing it up?
I'll go back to using numbers in the bound column, and lots of Select Case statements in my code.
Thank you for your attention.
Sep 21 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Porky Pig Jr | last post by:
Just downloaded and installed the latest Cygwin distribution which includes python 2.3.4. IDLE runs fine but for some reason the toolbar menu doesn't show up. Like, by default, it starts shell...
44
by: Mariusz Jedrzejewski | last post by:
Hi, I'll be very grateful if somebody can explain me why my Opera 7.23 (runing under linux) doesn't show me inner tables. Using below code I can see only "inner table 1". There is no problem with...
0
by: Elvisvr | last post by:
Does any body has an idea why the control doesn't show the string to be printed in the dialog??? //The event raised by: printPreviewDialog1.ShowDialog(); private void thedoc_PrintPage(object...
1
by: Carlos Gomez | last post by:
I'm using Visual Studio .NET to make a C++ DirectX application. My problem is that sometimes when I hit RUN, the application begin loading but doesn't show on the desktop, almost as if I had set...
2
by: Jim | last post by:
My browser doesn't show text boxes, labels etc. It seems that it doesn't read the script at all (C#). I use the following program (from a wrox book): <----------------------------------------...
2
by: John Holmes | last post by:
I would like to turn on a label control in javascript with the onfocus event of another control by setting the Visible property to true. When I try and reference this label control it says...
0
by: jrchase | last post by:
I have encountered a problem with displaying a string as a descriptor to a bound decimal value in a combo box. Here is a sample data set: Value Description 1.5 Low (Drop-down list...
7
by: Noorain | last post by:
hi i want go from one file to another file. but file name doesn't show in url. For examlpe: i want to visit http://www.home.com. Now i want to go to contact_us.php page. when i go this page...
0
by: msjann | last post by:
I have a Dell running Vista and Explorer doesn't show up at boot and when i press ctl-alt-del the task manager doesn't show up either so I'm not sure how to fix the problem...? Help please..
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.