473,473 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using combo-box as a user filter - trying to use format to display text "all" for null values

This is something I've done plenty of times in '97, but I can't seem to
get it to work correctly in Access 2003. Say, for example, I have a
form with an unbound combobox, the data source is a table of customers,
first column is the key field, which is hidden with a 0" width, and the
second column is the customer name. The SQL is a union query that also
inserts Null in the first column, and "All" in the second column. That
combobox gets used as criteria for a query, such that a value entered
by the user restricts the results to records that are related to that
customer, and choosing "All" results in that combobox having a null
value, which I use in the query to return records irrespective of the
customer.

Functionally, it works fine in 2003 as it did in '97: "All" shows up
in the combobox as a possible selection, and when it's selected, the
comboboxes value gets set to Null, which I use in the query to not have
the customer ID be a criteria in the results. The problem is in the
display: in '97, I could set the default value of that combobox to
Null, and the format of that field to @;"All", which would
automatically display "All" in that field when the form was opened,
showing that as a default, all customers would be returned. In 2003,
the combobox is blank. The value of the combobox is null, as it should
be, but the word "All" doesn't show up in that field until the user
pulls it down and selects All. I even have other controls that
programatically reset this combobox to Null, and in that case, it also
doesn't work: it is simply a blank display.

In short, the combobox will not display "All" on a null value UNLESS
that value was selected by the user. How do I get the combobox to
display a pre-defined string when the value of that control is Null,
even when the value wasn't set to Null directly by the user by
selection within the combobox?

Thanks!

Nov 13 '05 #1
3 4006
I'll just add, I've implemented a work-around: rather than using Null
as the value in the query's criteria to indicate that that field should
not be used to restrict results, I'm using -1. -1 is an impossible
value for a valid customerID field, as it's an autonumber, so in this
case I can use that just as easily as Null. I'd still, however, like
to understand why this doesn't work in 2003 like it does in '97.

Thanks again!

Nov 13 '05 #2
Yes, the first method listed there (using a union query), is exactly
what I'm doing to get "All" into the list of choices for the user.
When they select "All", the value of the combobox is set to Null, as it
should be. The problem I'm having is that I'm hiding the first column
(it's width is set to 0), and therefore what is displayed in the field
when the box is collapsed is the value of the second column in the row
source (in this case, either All, or the customer's name, corresponding
to either Null, or the customer's primary key field being stored as the
value for the control). If they select "Company ABC" in the drop down,
"Company ABC" remains visible in the combobox when it's collapsed, just
as it should. If they select "All" in the drop-down, "All" remains
visible in the control when it's collapsed, as it should. If I set the
value of the combobox control to 1 (either through code, or by setting
the default value of that control to 1 then opening the form), and 1
happens to be the primary key ID for "Company ABC", then "Company ABC"
is shown in the value of the combobox when the form wakes up, or when
the value is changed programatically, just as it should. In other
words, since the second column of the combobox is the first visible
field, when the value of the combobox is set programmatically, it
automatically displays the coresponding value from the second column.
This is what is NOT working with Null values: if the value of the
combobox is set to Null, it is NOT automatically displaying "All" in
the collapsed combobox, even though "All" is the corresponding value of
the second column to a Null value in the first column, as per the union
query as described in your link.

If I remember correctly, Access '97 behaved in a similar manner, in
that the second column wasn't automatically pulled in if Null was the
value of the first (bound) column. But in '97, I was able to work
around that by setting the format property to @;"All" (or possibly
;;;"All" with numerics, can't remember for sure). But using the format
property to display "All" for Null isn't working when the control is a
combobox with a row source such as this.

Perhaps my "new" workaround is simply the new solution to this in 2003,
but I'm still curious to see what others may have to say. :)

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nils Benson | last post by:
Here's a strange problem: I have an arbitrary query that has calculated columns in its output. It could be a "SELECT TOP 1 * FROM ...", or a "SELECT STDEV(somefield) FROM ...". It doesn't matter...
1
by: Leila | last post by:
Folks I have an html file which looks like this: .. .. .. <body onLoad="WindowOnLoad();"> .. ..
2
by: YM | last post by:
Hi, Need help making all values in the entire database negative regardless of what number is put in. If it's a VBA line, please indicate where I write it :) Thanks,
4
by: Jim in Arizona | last post by:
This doesn't make any sense to me. I'm hoping some SQL guru out there knows the answer. I'm making a help desk type database system. There's only two tables, one called TTickets and the other...
0
by: Ed | last post by:
All of a sudden my previously working code started throwing this error. from the SqlDatasource. I am using C# and Asp.net 2.0. Getting the following error: You have specified that your delete...
0
by: saddy | last post by:
hello i m using seagate crystal report and then i will use the same report in my vb.net application In the report i want to show the values of the table that was built in the SQL server 2000 ,...
22
by: Yakov | last post by:
What would be the nicest way to write the loop for all values of unsigned short (0..0xffff), usnig 'unsigned short port;' as an index ? For comparison, there is just one way to write the for(k=0;...
2
by: =?Utf-8?B?a2V2aW4=?= | last post by:
using VS2005 My masterpage has two panels and two hyperlinks. The initial content aspx page is blank. The page_load event of the masterpage hides one of the panels based on SESSION...
2
by: Roget | last post by:
Using a DetailsView and SQLDataSource controls I am passing three values through an InsertCommand into a SQL Server database. <asp:SqlDataSource ID="AP_ListData" runat="server"...
7
by: himanshupancholi | last post by:
Hi, I need to Copy all values of a column from one table to another. Below are the details: Source: STL_GRP table, VEND column Destination PARTNER table, VEND column. I am using the below...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.