473,699 Members | 2,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query Comma Delemited Textbox

I have a database where I need to query multiple items. Is it possible
to run a query based on a textbox where the information is delimited by
a comma.

Example:

Show me all names where Social Security Number:

[TEXTBOX] = 111223333, 444556666, 777889999

It seems to me a loop of some sort is needed.

Any suggestions would be great. Thanks!

Oct 17 '06 #1
6 2097
Drum,

You would need a loop to parse the values from the textbox...somet hing
like this:

Dim lNew as Boolean
Dim str as String
Dim aVals()
Dim idx as Integer

idx = 0
ReDim aVals(idx)

for i = 1 to len(TextBox)
If Mid(TextBox, i, 1) = "," then
lNew = True
End If

If Not lNew then
str = str & Mid(TextBox, i, 1)
Else
aVals(idx) = str
str = ""
idx = idx + 1
ReDim Preserve aVals(idx)
i = i + 1
End If
Next i

After parsing the values into an array, use the array to build your
query...

Hope this helps,
Brian
Drum2001 wrote:
I have a database where I need to query multiple items. Is it possible
to run a query based on a textbox where the information is delimited by
a comma.

Example:

Show me all names where Social Security Number:

[TEXTBOX] = 111223333, 444556666, 777889999

It seems to me a loop of some sort is needed.

Any suggestions would be great. Thanks!
Oct 17 '06 #2
Brian,

Thank you for the help.

Would you be able to elaborate more? I am rather new to MS Access.

Brian Puffer wrote:
Drum,

You would need a loop to parse the values from the textbox...somet hing
like this:

Dim lNew as Boolean
Dim str as String
Dim aVals()
Dim idx as Integer

idx = 0
ReDim aVals(idx)

for i = 1 to len(TextBox)
If Mid(TextBox, i, 1) = "," then
lNew = True
End If

If Not lNew then
str = str & Mid(TextBox, i, 1)
Else
aVals(idx) = str
str = ""
idx = idx + 1
ReDim Preserve aVals(idx)
i = i + 1
End If
Next i

After parsing the values into an array, use the array to build your
query...

Hope this helps,
Brian
Drum2001 wrote:
I have a database where I need to query multiple items. Is it possible
to run a query based on a textbox where the information is delimited by
a comma.

Example:

Show me all names where Social Security Number:

[TEXTBOX] = 111223333, 444556666, 777889999

It seems to me a loop of some sort is needed.

Any suggestions would be great. Thanks!
Oct 17 '06 #3

Drum2001 wrote:
I have a database where I need to query multiple items. Is it possible
to run a query based on a textbox where the information is delimited by
a comma.

Example:

Show me all names where Social Security Number:

[TEXTBOX] = 111223333, 444556666, 777889999

It seems to me a loop of some sort is needed.

Any suggestions would be great. Thanks!
I would use several textboxes if you can... otherwise, you'd have to
parse them all (you could use Split), but then passing the result of
the function to a query where you build the In([list]) is going to be
ugly. If you use unbound textboxes, then you can easily just create
your own IN statement. or OR statement.

Oct 17 '06 #4
I thought of the multiple textboxes.. though, we are looking at typing
50+ IDs at a time.

The textboxes are unbound, though...
pi********@hotm ail.com wrote:
Drum2001 wrote:
I have a database where I need to query multiple items. Is it possible
to run a query based on a textbox where the information is delimited by
a comma.

Example:

Show me all names where Social Security Number:

[TEXTBOX] = 111223333, 444556666, 777889999

It seems to me a loop of some sort is needed.

Any suggestions would be great. Thanks!

I would use several textboxes if you can... otherwise, you'd have to
parse them all (you could use Split), but then passing the result of
the function to a query where you build the In([list]) is going to be
ugly. If you use unbound textboxes, then you can easily just create
your own IN statement. or OR statement.
Oct 17 '06 #5

Drum2001 wrote:
I have a database where I need to query multiple items. Is it possible
to run a query based on a textbox where the information is delimited by
a comma.

Example:

Show me all names where Social Security Number:

[TEXTBOX] = 111223333, 444556666, 777889999

It seems to me a loop of some sort is needed.

Any suggestions would be great. Thanks!
You shouldn't need to do the extensive parsing that others have
suggested if your SSN field is numeric. For example, if your table was
called tblPeople and your textbox was called txtSSN and you wanted to
select all records with SSN's matching the ones listed in your textbox
you could create a query string as in the following example:

dim strSQL as string

strSQL = "select * from tblPeople where SSN in (" & txtSSN & ")"

HTH,
Bruce

Oct 17 '06 #6
If you are processing 50 people per record I would guess that you are not
going against
an MS Access db. Maybe the SSA db to validate SSNs?

What I think you need to think about is how you are going to receive,
evaluate and store
the results of the query. The data is going to get parsed. The only
questions are when, by what method and on what machine. Big iron can do the
parsing very efficiently but if you query 50 at a time then someone at your
end has to go back and figure out what the results were vis a vis the
request and the returned data and in the mean time several other iterations
of another 50 and another 50 have gone and returned more data.

If the data coming back is ordered by individual SSN and you have 50 SSNs in
a string (for each record) good luck matching it up. That's where Clerks
used to get jobs, comparing output documents to input documents.

Getting feedback on 50 SSNs would mean that you would again have to parse
the string to determine what your results were at the individual SSN level
which is probably your level of interest.

If it were mine I would parse the data to fields of single SSNs. You could
then build whatever string you want to issue a query. If you have someone
type 50 SSNs with comma delimiters into a field, how do you reliably know
which SSNs you have been accurately queried?

<de************ ***@gmail.comwr ote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
>
Drum2001 wrote:
>I have a database where I need to query multiple items. Is it possible
to run a query based on a textbox where the information is delimited by
a comma.

Example:

Show me all names where Social Security Number:

[TEXTBOX] = 111223333, 444556666, 777889999

It seems to me a loop of some sort is needed.

Any suggestions would be great. Thanks!

You shouldn't need to do the extensive parsing that others have
suggested if your SSN field is numeric. For example, if your table was
called tblPeople and your textbox was called txtSSN and you wanted to
select all records with SSN's matching the ones listed in your textbox
you could create a query string as in the following example:

dim strSQL as string

strSQL = "select * from tblPeople where SSN in (" & txtSSN & ")"

HTH,
Bruce

Oct 18 '06 #7

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

Similar topics

2
1548
by: Keith Doran | last post by:
I have a webform page that contains a textbox control. The textbox is initialized by the codebehind module and contains a value when the page is first loaded. The user can then edit the textbox if they choose to or leave it as is. The strange behavior I'm seeing is that when the form is posted back to the server, the textbox's text property contains the new value followed by a comma and then the original value. eg. if the control...
11
1525
by: Daniel Seipel | last post by:
I'm new at ASP and I'm trying to query an MS SQL database (Northwind). I want the page to be setup with a textbox where the user inputs a list of comma separated numbers and the query would be something like: select * from categories where categoryid in ('1','2','3','4','5') and the results would be in a datagrid, I think. This is easy in Query analyzer but putting it on a web form seems very hard.(for me) This doesn't seem...
6
4843
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID SalesManName AT Alan Time
2
1395
by: fong.yang | last post by:
Need help setting a select query where person enters a list of zipcodes to lookup. I want to prompt the user to enter all the zip codes, then run the query against to table to pull all records. Thanks.
19
8520
by: M. Posseth | last post by:
Hi ,, i live in Europe in Europe the decimal seperator is , not a . why is it so that if i press on my numeric keypad the . a . appears ?? in my opinion it should be a , ( sounds odd but ... it should be so ) my problem : i work currently in a companny where people do data entry with the numeric
1
2496
by: Intrepid_Yellow | last post by:
Hi, I have the following code that runs my report generator. The user selects a table from a combo box, then whatever fields they want from a list box. (This part all works and the report runs fine). There is then a combo box they can select a field from (eg CompanyID etc) and then the list box below that contains the values (eg Microsoft, Novell etc). These are all multi-select list boxes. Now I can get the code to work if the user...
3
2160
by: Phil Stanton | last post by:
I have a number of queries which use code for the output of 1 or more fields. For example Address:GetAddress(AddressID, True, 60) Address ID Points to an Address in a table - Address Line1, Line 2, Line 3, Town, County, Post Code, Country. The True is whether to include the country and the 60 is the maximum line length (after which a line feed is inserted). All this is to output to a formatted RTF file for a handbook. In addition, I...
7
7851
by: Joza | last post by:
Hi! How to replace dot with comma when user is typing somewhat in textBox? I have wrote this part of code to detect typed dot, but how to replace it with coma: private void txtNum_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (int)(char)'.') {
3
2387
by: premprakashbhati | last post by:
sir, how to put dynamic comma after 12 characters in textbox means 13th char is comma.... can u plz suggest me ...how i should do it... thanx... prem prakash...
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9171
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
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 we have to send another system
3
2008
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.