472,984 Members | 2,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Combining two different data types in a listbox

I currently have a list box that contains regions in the US
(Northeast, Midwest, South, etc.). I am retrieving this data from my
Region table(see below). Users have the ability to select a region as
part of a search. The results were too broad so we had to make an
Office table.

Region Table
RegionCd varchar(2)
RefionDesc varchar(50)

Office Table
OfficeId Int
OfficeName varchar(50)
RegionCd varchar(2)

What I want to do is load a listbox so that it has the region first
and then all the related offices below it:

Midwest
Chicago
Des Moines
Northeast
Boston
New York
....

The problem here would be that the region code is a two character
varchar code and the office is an integer. How can I combine in one
list box to perform my search?
Jul 19 '05 #1
4 2375
One idea is to prefix the region codes with RC and office codes with OC, and
trap these in your search, and proceed.

<item id="RC12">Midwest
<item id="OC12"> Chicago

Then on the server side,

If Left(Request.Form("itemid"), 2) = "RC"
... string search
Else
... integer search
End If

Hope that helps.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"John" <jr****@yahoo.com> wrote in message
news:f8**************************@posting.google.c om...
I currently have a list box that contains regions in the US
(Northeast, Midwest, South, etc.). I am retrieving this data from my
Region table(see below). Users have the ability to select a region as
part of a search. The results were too broad so we had to make an
Office table.

Region Table
RegionCd varchar(2)
RefionDesc varchar(50)

Office Table
OfficeId Int
OfficeName varchar(50)
RegionCd varchar(2)

What I want to do is load a listbox so that it has the region first
and then all the related offices below it:

Midwest
Chicago
Des Moines
Northeast
Boston
New York
...

The problem here would be that the region code is a two character
varchar code and the office is an integer. How can I combine in one
list box to perform my search?

Jul 19 '05 #2
"John" <jr****@yahoo.com> wrote in message
news:f8**************************@posting.google.c om...
I currently have a list box that contains regions in the US
(Northeast, Midwest, South, etc.). I am retrieving this data from my
Region table(see below). Users have the ability to select a region as
part of a search. The results were too broad so we had to make an
Office table.

Region Table
RegionCd varchar(2)
RefionDesc varchar(50)

Office Table
OfficeId Int
OfficeName varchar(50)
RegionCd varchar(2)

What I want to do is load a listbox so that it has the region first
and then all the related offices below it:

Midwest
Chicago
Des Moines
Northeast
Boston
New York
...

The problem here would be that the region code is a two character
varchar code and the office is an integer. How can I combine in one
list box to perform my search?


At first, I thought you wanted an OPTGROUP:
http://www.w3.org/TR/html4/interact/forms.html#h-17.6

But I assume you want to be able to pass EITHER the region or the office in
your search.

As for combining them... I assume you are asking how to combine them with a
SQL statement? Something like this:

SELECT
Region.RegionCd, Region.RegionDesc, Office.OfficeId, Office.OfficeName
FROM
Region
INNER JOIN
Office
ON
Region.RegionCd = Office.RegionCd
ORDER BY
Region.RegionDesc, Office.OfficeName

This would give you a recordset like:

1, Midwest, 1, Chicago
1, Midwest, 3, Des Moines
2, Northeast, 2, Boston
2, Northeast, 4, New York

Use those values as the values for your select options, but perhaps prepend
something to each that identifies weather it's an OfficeID or a RegionCd.
For example:

<select name="foo">
<option name="R1">Midwest</option>
<option name="O1">Chicago</option>
<option name="O3">Des Moines</option>
<option name="R2">Northeast</option>
<option name="O2">Boston</option>
<option name="O4">New York</option>
</select>

Then on the page that this gets submitted to, take the value of "foo", strip
off the first character to see whether it's R for Region or O for Office,
and then use the rest of the value for performing the search as needed.

Hope this helps.
Regards,
Peter Foti

Jul 19 '05 #3
Thanks. Then on my stored procedure I will have to do some sort of
If..Then to search by Office or Region. Depending on which was
selected. Correct?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4
"Amy Snyder" <am**@yahoo.com> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
Thanks. Then on my stored procedure I will have to do some sort of
If..Then to search by Office or Region. Depending on which was
selected. Correct?


Close. I imagine you would probably want to have 2 stored proceedures...
one to search by Office, and one to search by Region. Then, on the page
that you submit the form to, you would call the appropriate stored
proceedure based on which value was selected.

Regards,
Peter
Jul 19 '05 #5

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

Similar topics

2
by: Balrog | last post by:
Hi! I wonder if anyone could give me some hints/pointers. This is what I'm trying to do: say, I have the following: - data (most likely XML) Example: <colour>red</colour> - data validation...
15
by: Phillip Rhodes | last post by:
Hi all, I have a question I hope someone can help me with: I'm doing some communication over a socket, and have need to send and receive values of type double. I'm doing everything in terms of...
1
by: ravi | last post by:
I have created the following interest to calculate the interest for the following currency pairs. I have tried to combine them in macros using conditions but the next query that is run in the macro...
1
by: PATGMorris | last post by:
I've got a Union Query that pulls data from two different tables for chemistry and micro testing. The tables containing very similar data but for reasons not necessary here, cannot be put into one...
7
by: James CC | last post by:
Hi there, I have a function, converted from VB, that is passed an object, and sets it up. The object passed is either a ListBox or a ComboBox. The code checks to make sure that the object passed...
11
by: Brian | last post by:
Hi! I am new to VB.net but know enough to kind of dive in. I want to make a text adventure but I am having problems in how I want to store the data for inventory items, characters and such....
2
by: hp3k | last post by:
Hi, I'm a newbie to VB .Net and am unable to locate an example of combine two different font types (Arial and Wingdings 3) in a display (text) string. Does anyone have an example of combining...
2
by: Dynamo | last post by:
Hi there, I have a curious problem I can't seem to solve. I have a list box that gets filled with data, the user selects an item in this list, then a form view displays the full details from...
5
by: girays | last post by:
I want to make a good design about combining information. Suppose you have different data types, and each may have semantically same data. I want to merge these different data types into a single...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.