473,325 Members | 2,480 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,325 software developers and data experts.

Wildcard parameters in code

I have a list of contract numbers like

123-4-567-890

I want to be able to search by any subsequence of numbers like:

123 - # - 4567 - ###

I have 4 list boxes with all instances of each number respectively. I
have another list box where I want the result of the query.

How is this done effectively?

Initially I had a parameter query that fetched the values from the
form like this:

[forms]![frmTG_CONT_2]![combo149] Or [forms]![frmTG_CONT_2]![combo149]
Is Null
[forms]![frmTG_CONT_2]![combo151] Or [forms]![frmTG_CONT_2]![combo151]
Is Null
[forms]![frmTG_CONT_2]![combo153] Or [forms]![frmTG_CONT_2]![combo153]
Is Null
[forms]![frmTG_CONT_2]![combo155] Or [forms]![frmTG_CONT_2]![combo155]
Is Null

under each subnumber respectively.

This was terrifyingly slow. Is there a better way?

I also attempted this which didn't work (Chr(42) is an astrix.):
----
Private Sub ListClick()

Dim String1 As String
Dim String2 As String
Dim String3 As String
Dim String4 As String
If IsNull(Me.Combo149) Then
String1 = Chr(42)
Else
String1 = Me.Combo149
End If
If IsNull(Me.Combo151) Then
String2 = Chr(42)
Else
String2 = Me.Combo151
End If
If IsNull(Me.Combo153) Then
String3 = Chr(42)
Else
String3 = Me.Combo153
End If
If IsNull(Me.Combo155) Then
String4 = Chr(42)
Else
String4 = Me.Combo155
End If
Me.Text175 = "like " & String1 & String2 & String3 & String4
Me.List172.Requery

End Sub

------
Christian

Apr 11 '07 #1
1 2119
This kind of search will be slow. When you use wildcards (except at the end
of the string), Access cannot just look up an index for the values, so it
must do an entire table scan. With many tens of thousands of records, there
will be significant pauses.

If the field contains dashes, you will also encounter this problem:
http://support.microsoft.com/kb/271661/en-us

The way you presented the contract number, separated by dashes, suggests
that these numbers may have a meaning? If the 123 represents one thing, and
the last 3 digits represents something else, would you consider breaking
these into separate fields? One of the basic rules of normalization is to
make the data atomic, i.e. only store one thing in one field. Just as you
store City, State, and Zip in separate fields, if this contract number is
made up of atomic parts, you might consider splitting it into separate
fields.

The advantage is that you could then index each field, and perform an index
search on just those fields. This solves the problem with the dashes, and
will give you instantaneous results.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<ch************@yahoo.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
>I have a list of contract numbers like

123-4-567-890

I want to be able to search by any subsequence of numbers like:

123 - # - 4567 - ###

I have 4 list boxes with all instances of each number respectively. I
have another list box where I want the result of the query.

How is this done effectively?

Initially I had a parameter query that fetched the values from the
form like this:

[forms]![frmTG_CONT_2]![combo149] Or [forms]![frmTG_CONT_2]![combo149]
Is Null
[forms]![frmTG_CONT_2]![combo151] Or [forms]![frmTG_CONT_2]![combo151]
Is Null
[forms]![frmTG_CONT_2]![combo153] Or [forms]![frmTG_CONT_2]![combo153]
Is Null
[forms]![frmTG_CONT_2]![combo155] Or [forms]![frmTG_CONT_2]![combo155]
Is Null

under each subnumber respectively.

This was terrifyingly slow. Is there a better way?

I also attempted this which didn't work (Chr(42) is an astrix.):
----
Private Sub ListClick()

Dim String1 As String
Dim String2 As String
Dim String3 As String
Dim String4 As String
If IsNull(Me.Combo149) Then
String1 = Chr(42)
Else
String1 = Me.Combo149
End If
If IsNull(Me.Combo151) Then
String2 = Chr(42)
Else
String2 = Me.Combo151
End If
If IsNull(Me.Combo153) Then
String3 = Chr(42)
Else
String3 = Me.Combo153
End If
If IsNull(Me.Combo155) Then
String4 = Chr(42)
Else
String4 = Me.Combo155
End If
Me.Text175 = "like " & String1 & String2 & String3 & String4
Me.List172.Requery

End Sub

------
Christian
Apr 12 '07 #2

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

Similar topics

1
by: Generic Usenet Account | last post by:
Here's the requirement that I am trying to satisfy: Handle wildcards in STL such that the wildcard entry is encountered before non-wildcard entries while traversing containers like sets and...
1
by: deko | last post by:
I have a form where users can enter a string with asterisks to perform a wildcard search. Currently, the string entered by the user looks like this: *somestring* The purpose is to match any...
0
by: Mark | last post by:
I have some code that starts with... SqlConnection conn = new SqlConnection(Globals.ConnectionString); conn.Open(); try { SqlCommand command = new SqlCommand("SELECT cusid, cusname FROM...
2
by: JohnT | last post by:
Okay... I'm using VB.net (2003) and I am accessing an MS Access DB file. I have two DataAdapters that I use to search for specific info. The two of them are similar except one is a Date, the...
78
by: wkehowski | last post by:
The python code below generates a cartesian product subject to any logical combination of wildcard exclusions. For example, suppose I want to generate a cartesian product S^n, n>=3, of that...
0
by: Thomas | last post by:
in .net 1.1 we successfully use a HttpModule to catch 404 / 403.1 html errors. after migrating to .net 2.0, this modules is broken in a very, very strange way. we have defined a wildcard...
6
by: Jan Kucera | last post by:
Hi, does anybody know about wildcard mapping ASP.NET 2 in IIS6? Any tutorial? Thanks, Jan
4
by: Dave | last post by:
This is my query named "spVOC_Sp_Example_search" in Access 2003: PARAMETERS Text ( 255 ); SELECT Example.Example FROM Example WHERE (((Example.Example) Like "*" & & "*")); It works great: ...
3
by: =?Utf-8?B?Um9kbmV5IFZpYW5h?= | last post by:
IIS 6 SQL Injection Sanitation ISAPI Wildcard at http://www.codeplex.com/IIS6SQLInjection I created an ISAPI dll application to prevent SQL Injection attempts by intercepting the HTTP requests...
0
by: savage678 | last post by:
Hi Everyone, I am new to this forum and am i dire need of some help. I am trying to use wildcard searches in infopath. I have it connected to an access database using data connection. I have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.