473,595 Members | 2,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8384
"John R" <jo*********@SP AMhotmail.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*******@eart hlink.net> wrote in message
news:fa******** *************** **@posting.goog le.com...
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*********@SP AMhotmail.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*********@SP AMhotmail.com> wrote in message
news:3f******** *************** @news.optusnet. com.au...
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("Phone Number"),Len(ar rayPrefix(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("Phone Number"),Len(ar rayPrefix(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
2253
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 "looked up", for example: if firstPair == '01' then variable = "Monkey"; else if firstPair == '02' then variable = "Chicken"; etc..
3
1655
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 generated. The user obtains the code from his/her supervisor and inputs it to allow the operation to continue. In VBA the authorisation is checked (DLookUp) for validity. I have activated full security but find that obviously DLookup will only work if there is read permission for the table. But...
1
3353
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 values. I created a form using the dataform wizard. As part of the setup, I specified a new dataset, which included the data & lookup tables. I also specified the relationships when required. I then added a combo box control to my form, following the instructions from
3
2278
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 see the values of the combobox selections rather than the key value that are stored in the table. It works well if the comboboxes are selected when the row is created.
11
2641
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. 1. A plain text field Create a text field in tblPeople called PreferredPet. 2. A lookup field that stores text values. Create a text field in tblPeople called PreferredPetID and use it to lookup an identical text field in tblPreferredPets.
5
4006
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 lookup table of usernames, I need to use this lookup table in all my other forms to update different table selecting the username from my lookup table. I tried Docmd.runsql but unable to succeed.
5
12651
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 name and id and are stored in sql server. I need to create single line combobox style control which: 1. Allows to type first characters in name 2. Auto-completes entered data by using first match 3. Allows to open picklist based by entered data and select name
4
6637
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" which looks like this: Sourceabbrev Sourcename BX-MI BUILDERS EXCHANGE MI BX-OH BUILDERS EXCHANGE OH CNS-MI CONSTRUCTION NEWS SERVICE MI
0
1257
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 having trouble with getting the main data source to update after updates to a lookup table. There are 2 tables with a one-to-many relationship in the mdb. VB.Net recognizes this relationship according to it's dataset designer diagram. Currently I have 2 forms: a main form for data-entry and a...
0
7955
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
8261
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...
1
8019
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
8251
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6674
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5839
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3873
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...
1
2391
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
0
1223
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.