Ok need a litle help on this one guys.
I have a combo box that displays value from a Category table and the selected value will be stored in my Contact table.
No problem there that part works fine.
What I would like to do is display a value called "Not Assigned" at the top of the combo box all the time. The value of "Not Assigned" is NOT stored in the Category table. I am trying to accomplish this without storing "Not Assigned" in the Category table.
If this can be done the value of CategoryID should be assigned the number 0 and stored in the Contact table.
Category table as 3 fields
CategoryID - Autonumber - PK
CategoryDesc - Text - ie: Client, Vendor, etc.
CategoryColour - Text - used to store a hex number
CategoryID is the FK in my Contact table
The combo box currently has the following properties:
Control Source - CategoryID
Row Source - SELECT [tContactCategory].[CategoryID], [tContactCategory]. [CategoryDesc] FROM tContactCategory ORDER BY [CategoryDesc];
Bound Column - 1
Column Count - 2
Column Widths - 0,1
Any ideas?
cheers,
6 1361
Just subscribing, will check in later.
- 'To display Not Assigned (leading Space)
-
SELECT tContactCategory.CategoryID, tContactCategory.CategoryDESC
-
FROM tContactCategory
-
UNION
-
SELECT '0', ' Not Assigned'
-
FROM tContactCategory
-
ORDER BY tContactCategory.CategoryDESC;
- 'To display (Not Assigned)
-
SELECT tContactCategory.CategoryID, tContactCategory.CategoryDESC
-
FROM tContactCategory
-
UNION
-
SELECT '0', '(Not Assigned)'
-
FROM tContactCategory
-
ORDER BY tContactCategory.CategoryDESC;
NeoPa 32,556
Expert Mod 16PB
Try this. It brings in just one line to add to the results from [tContactCategory]. - SELECT [CategoryID],[CategoryDesc]
-
FROM tContactCategory
-
UNION SELECT Max(0),Max('Not Assigned')
-
FROM tContactCategory
-
ORDER BY [CategoryDesc]
Let us know how you get on with these :)
Thanks guys I won't be able to try it until about Wednesday. This personal project has to be put on the back burner for paying projects (lol). I'll let you know.
cheers,
Thanks guys. I got a few minutes tonight to look at it.
Dezi your way was the way I tried originally but I reversed my Union query and it didn't work. Your way worked so I assumed I was originally on the right track and I made a slight change to your suggestion to allow any value in the CategoryDescription and not have to worry about putting leading spaces or brackets to force it on top. I created a new orderby (See below) that takes care of the ordering and is more flexible.
Neo I couldn't get yours to work but I haven't had much time to examine it. I will look around Wednesday when I get more time to analyse it.
Thanks guys. -
SELECT tContactCategory.CategoryID, tContactCategory.CategoryDESC, 1 AS SortOrder FROM tContactCategory UNION Select '0' AS CategoryID, 'Not Assigned' AS CategoryDesc, 0 FROM tContactCategory ORDER BY SortOrder, tContactCategory.CategoryDESC;
-
cheers,
NeoPa 32,556
Expert Mod 16PB
I missed that you needed it at the top :( Is that what you meant when you said you couldn't get it to work?
Try this anyway and let me know : - SELECT [CategoryID],[CategoryDesc],1 AS [CatSort]
-
FROM tContactCategory
-
UNION SELECT Max(0),Max('Not Assigned'),Max(0)
-
FROM tContactCategory
-
ORDER BY [CatSort],[CategoryDesc]
You may have to adjust the ComboBox to allow for, but not show, the third column ([CatSort]), or even reorder the columns as you see fit.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Reggie |
last post by:
Hi and TIA! I have a bound combobox with rowsource set to value list, limit
to list=true and NotInList procedure to add(or not) a value the user types
in. This works fine and it does add the...
|
by: MS |
last post by:
What's the best way to "store" and display a value in a text box that
changes from day to day. An example of this would be where the name of the
user is manually typed in after using the datbase,...
|
by: Dave |
last post by:
I have a problem which I know there is an answer to but have so far been
unsuccessful in finding it. It is quite simple in theory. I have created a
form which uses a table for lookup values and...
|
by: ILCSP |
last post by:
Heello, I'm using Access 2000. I have a form with a combo box that has
a query as its row source and it's bound to column 1. This combo box
is unbound to a record like the rest of the form...
|
by: Gav |
last post by:
I am using VS 2005 and am trying to add items to a combo box using C#. I
know how to add simple text items but I am trying to add a value and some
text ie.
Value Text
A First Text
B ...
|
by: Aaron Ackerman |
last post by:
I have a bound combobox the appears on a cell within the column of my bound
grid when the user clicks on a cell n(In my vb.net WinForm app).
I am trying to allow the adding of an item to that bound...
|
by: vb |
last post by:
Hi,
I am new to .Net.
I am using a Combo Box in my windows forms. I am adding the items by
creating the instances and adding the same to the list.
My questions/doubts are:
1. If I have 25 to...
|
by: Shawn Yates |
last post by:
It has been a while since I have done anything on MS Access and I seem
to be a bit rusty. I hope someone could help me solve my issue. I have
a form that has multiple combo boxes on it. Each box...
|
by: The Eclectic Electric |
last post by:
I'd be very grateful if anyone could help me with this. From my limited
knowledge of Javascript I don't think it is possible, but I'll punt anyway.
I downloaded and very slightly adapted this...
|
by: =?Utf-8?B?Y2RtdW5veg==?= |
last post by:
I have created a sub routine to programmatically add an indefinite number of
combo boxes to a form. The combo boxes are bound in code to a view for
displaying the available options. This routine...
|
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,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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...
| |