472,325 Members | 1,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Number Prefix Lookup Table in MDB

Hi all,

I'm trying to get my VB6 app to look up prefixes for a phone number out of
an MDB file along with an associated price etc.

For example the phone number could be 9802xxxx, and the MDB file will have
the record 9802 with an associated price.

I am used to connecting to databases via ADO, but my problem is that the MDB
file may contain prefixes from 1 to 5 chars in length and i'm not sure how
to get VB to find the best match.

I'm assuming it can be done with a very large nested IF statement, is there
a better way?

Cheers,
John
Jul 17 '05 #1
6 8307
"John R" <jo*********@SPAMhotmail.com> wrote in message news:<3f***********************@news.optusnet.com. au>...
Hi all,

I'm trying to get my VB6 app to look up prefixes for a phone number out of
an MDB file along with an associated price etc.

For example the phone number could be 9802xxxx, and the MDB file will have
the record 9802 with an associated price.

I am used to connecting to databases via ADO, but my problem is that the MDB
file may contain prefixes from 1 to 5 chars in length and i'm not sure how
to get VB to find the best match.


he exmaple you give matches the first 4 digits of an 8-character code
against a field that is an exact match. That seems like a simple
query. You then say it can be 1-5 characters and you want the "best
match" but don't explain what the possible matches are or which would
be better than others... can you elaborate with some more examples
include good/better/best matches?
Jul 17 '05 #2
Thanks for the reply Bob, let me see if i can explain it a bit better.

I am trying to parse an output file from a PABX phone system. I have an MDB
file with aprox 200 prefixes which rance from 1-5 chars in length (eg:
country codes, national & local telephone codes).

as an example, an international number dialled might be: 001161290000000,
and this would correspond to the record '0011' (int. call prefix) in the
MDB file. yet a local number would be just 90000000, and correspond to the
record '9' as long as there is no record '90' etc. So you can see my dilemma
with length of strings.

It will always be an exact match, but i may have the strings "9" "90" and
"901", the number "9058321" would have to be matched to "90" in the
database and "921345" would have to match just "9".

I was thinking of a large IF statement starting with LEFT(string,5), if it
finds no match move on to LEFT,4 and etc all the way to 1.

Is there a better way? if not whats the best way of organising an if
statement that large?

Cheers,
John R.

"Bob Butler" <bu*******@earthlink.net> wrote in message
news:fa*************************@posting.google.co m...
he exmaple you give matches the first 4 digits of an 8-character code
against a field that is an exact match. That seems like a simple
query. You then say it can be 1-5 characters and you want the "best
match" but don't explain what the possible matches are or which would
be better than others... can you elaborate with some more examples
include good/better/best matches?

Jul 17 '05 #3
On Thu, 4 Dec 2003 23:57:34 +1100, "John R"
<jo*********@SPAMhotmail.com> wrote:
Thanks for the reply Bob, let me see if i can explain it a bit better.

I am trying to parse an output file from a PABX phone system. I have an MDB
file with aprox 200 prefixes which rance from 1-5 chars in length (eg:
country codes, national & local telephone codes).

as an example, an international number dialled might be: 001161290000000,
and this would correspond to the record '0011' (int. call prefix) in the
MDB file. yet a local number would be just 90000000, and correspond to the
record '9' as long as there is no record '90' etc. So you can see my dilemma
with length of strings.

It will always be an exact match, but i may have the strings "9" "90" and
"901", the number "9058321" would have to be matched to "90" in the
database and "921345" would have to match just "9".

I was thinking of a large IF statement starting with LEFT(string,5), if it
finds no match move on to LEFT,4 and etc all the way to 1.

Is there a better way? if not whats the best way of organising an if
statement that large?


If you only have 200 prefixes to deal with, then I would pull the lot
out into an Array
- pound them into a standard format
- and do a Binary Chop

If I understand your problem correctly, you need to re-format the data
and the search key (using the same routine)

At which point the problem disappears
eg:
A single '9'
would find its best match if it were looking for '9' + Chr$(32)
Jul 17 '05 #4
Can you explain this 'routine' a little better?

Cheers,
John R
If you only have 200 prefixes to deal with, then I would pull the lot
out into an Array
- pound them into a standard format
- and do a Binary Chop

If I understand your problem correctly, you need to re-format the data
and the search key (using the same routine)

At which point the problem disappears
eg:
A single '9'
would find its best match if it were looking for '9' + Chr$(32)

Jul 17 '05 #5

"John R" <jo*********@SPAMhotmail.com> wrote in message
news:3f***********************@news.optusnet.com.a u...
Can you explain this 'routine' a little better?

Cheers,
John R
If you only have 200 prefixes to deal with, then I would pull the lot out into an Array
- pound them into a standard format
- and do a Binary Chop

If I understand your problem correctly, you need to re-format the data and the search key (using the same routine)

At which point the problem disappears
eg:
A single '9'
would find its best match if it were looking for '9' + Chr$(32)



1. Load the 200 prefixes into a recordset, and sort them by Len(Prefix)
DESC, so the longest are first.
2. Copy the records into an array.
3. Run through the phone number records, and for each one, scan the
array for a match.
4. Store the correct prefix in each phone number record, so you don't
have to do it again.
5. The loop for one record might look something like
For n =1 to 200
If (Left(rs("PhoneNumber"),Len(arrayPrefix(n)) =
arrayPrefix(n) Then
rs("Prefix") = arrayPrefix(n)
rs.Update
Exit For
next n
6. Make the array and matching function available for new and edited
records, so they get their prefix assigned when they are entered or
updated.

Jul 17 '05 #6
Thats a good way of doing it! Thankyou all.

If you only have 200 prefixes to deal with, then I would pull the lot out into an Array
- pound them into a standard format
- and do a Binary Chop

If I understand your problem correctly, you need to re-format the data and the search key (using the same routine)

At which point the problem disappears
eg:
A single '9'
would find its best match if it were looking for '9' + Chr$(32)



1. Load the 200 prefixes into a recordset, and sort them by Len(Prefix)
DESC, so the longest are first.
2. Copy the records into an array.
3. Run through the phone number records, and for each one, scan the
array for a match.
4. Store the correct prefix in each phone number record, so you don't
have to do it again.
5. The loop for one record might look something like
For n =1 to 200
If (Left(rs("PhoneNumber"),Len(arrayPrefix(n)) =
arrayPrefix(n) Then
rs("Prefix") = arrayPrefix(n)
rs.Update
Exit For
next n
6. Make the array and matching function available for new and edited
records, so they get their prefix assigned when they are entered or
updated.


Jul 17 '05 #7

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

Similar topics

2
by: cjl | last post by:
Hey all: I need to get some user input which will be a six digit number. I will split it into two character pairs. Each pair will need to be...
3
by: Chris | last post by:
I have a lookup table which contains authorisation codes for a particular operation. When a user makes a booking a random reference number is...
1
by: James | last post by:
I am used to VB6 but need to develop something in .Net. I need to create several bound combo-boxes which will use lookup tables to get their...
3
by: dbuchanan | last post by:
Hello, (Windows forms - SQL Server) I fill my datagrid with a stored procedure that includes relationships to lookup tables so that users can...
11
by: Paul H | last post by:
Suppose I have a table called tblPeople and I want a field to illustrate whether each person prefers cats or dogs. I could do it one of three ways....
5
by: sensreview | last post by:
Hello, I need help in selecting a value from combo list thru one lookup table and update different table on MS access form. For eg; I have a...
5
by: Andrus | last post by:
I'm creating a database Winforms application using VCS Express 2005 I have some large lookup tables (may be up to 500000 records) which contains...
4
by: TinaF | last post by:
I want to set a default value in a table called "Quotes" for a field called "Source." The "Source" field uses a lookup table called "Source"...
0
by: =?Utf-8?B?RU1hbm5pbmc=?= | last post by:
(I originally posted this to the data access newsgroup but received no replies) I've got an Access 2003 mdb that I'm converting to VB.Net. I'm...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.