473,545 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sort customers by postcode and print reports .

Hi,
I am a very beginner in databases. I created a database table in Access 2003
and OOo 2.03 that includes name, address, postcode, phone numbers etc of our
customers. I would like to sort customers by areas of London, UK by the
first part of the postcode. The London postcodes are the form of E19 4PR,
NW5U 4RT. So I would like to print a report (customers arranged into Word
tables - normal tables, not database tables) for example which includes the
following zones of London: North East, East and South London and which are
represented by the following postcodes E(1-18), SE(1-29), SW(1-29).
Thanks,
Julian
Aug 3 '06 #1
6 3360

"Julian" <x@x.xwrote in message news:4j******** ****@individual .net...
Hi,
I am a very beginner in databases. I created a database table in Access
2003
and OOo 2.03 that includes name, address, postcode, phone numbers etc of
our
customers. I would like to sort customers by areas of London, UK by the
first part of the postcode. The London postcodes are the form of E19 4PR,
NW5U 4RT. So I would like to print a report (customers arranged into Word
tables - normal tables, not database tables) for example which includes
the
following zones of London: North East, East and South London and which are
represented by the following postcodes E(1-18), SE(1-29), SW(1-29).
It is relatively simple to include a Calculated Field in your Query that
returns a "sort order" value for the postal codes as you describe. It is
not clear to me exactly the order you desire, so I won't suggest a
particular algorithm, but you'll use embedded IIFs.

It is also not clear to me what your goal is for "(customers arranged into
Word tables - normal tables, not database tables)." Unless you plan to
manually modify the output, there is not always an advantage in doing so. I
have not had exceptionally good luck with formatting being well-preserved
when I export Reports to "Word format" (actually RTF) and using COM
Automation to build Report output with Word can require a lot more work than
creating Access Reports.

If, however, you are going to create Access Reports, then you will use the
Report's Sorting and Grouping properties to define the sorting and grouping.

Larry Linson
Microsoft Access MVP

Aug 3 '06 #2
Your sorting is a issue of your report generator, or your query builder.

From your question, it sounds like you are not using ms-access at all..but
just opening the file for use...

the above being the case, you will need to ask your question in a oo
newsgroup. This sorting issue will be that of your
query builder, or report generator used...in your case oo

If you actually are building the queries and reports in ms-access, then
simply use the sorting and grouping option of the report...

If you are using a differnt product to build the reprots..then consult the
help/manuals for that product, or try their newsgroup..
--
Albert D. Kallal
Edmonton, Alberta Canada
pl************* ****@msn.com
Aug 3 '06 #3
It is relatively simple to include a Calculated Field in your Query that
returns a "sort order" value for the postal codes as you describe. It is
not clear to me exactly the order you desire, so I won't suggest a
particular algorithm, but you'll use embedded IIFs.
I would like to sort out customers by zones North, East etc, zones which are
defined by various postcodes. For example the North zone would be defined by
N(1-20), WD(1-24), NW(1-10). So, how do I make a query like: if the
customer's postcode starts with N(1-20), WD(1-24), NW(1-10), than sort them
into the North zone customers. Then create a report with these customers
that looks like a table (the one with rows and columns and borders) created
in Word, so I can print it. See what I mean at: ftp://87.112.95.111/
user: anonymous, no password.

It is also not clear to me what your goal is for "(customers arranged into
Word tables - normal tables, not database tables)." Unless you plan to
manually modify the output, there is not always an advantage in doing so.
I
have not had exceptionally good luck with formatting being well-preserved
when I export Reports to "Word format" (actually RTF) and using COM
Automation to build Report output with Word can require a lot more work
than
creating Access Reports.

If, however, you are going to create Access Reports, then you will use the
Report's Sorting and Grouping properties to define the sorting and
grouping.

See above.

Julian
Aug 4 '06 #4
I use Access. See my reply above.
Aug 4 '06 #5

"Julian" <x@x.xwrote in message news:4j******** ****@individual .net...
>I use Access. See my reply above.
ok...just not clear what the reference and information about oo was all
about...it just serves to confuse the issue, or introduce extra complexities
here. (what does oo have to do this problem then????).

Anyway....

The first problem you need to tackle is that of stripping out the postal
codes. You don't mention if your files are large, or small.

If your data file is only 5000-8000 records, then you likely can process the
records in place. If you have more records, then I would introduce two new
fields into the database.

Region
This field would hold the region

eg: E19 4PR, we set region = E
NW5U 4RT. we set region = NW
etc. etc. etc.

I would then create a another field called RegionN
RegionN
This field would hold the number, such as

eg: E19 4PR, we set RegionN = 19
NW5U 4RT. we set RegionN = 5
etc. etc. etc.

Once we do the above, then we would be able to obtain decent performance.
the above type of string processing could be done for each query, but that
would make for difficult queries.

So, I would add the two fields, and then run a update query to pull/put in
the region values into that new region field in the table....

I would then run another update query to put in the regionNUM vales into
that

Once the above is done, then the query you ask for would be easier to
write....eg
E(1-18), SE(1-29), SW(1-29)

(Region = "E" and (RegionN between 1 and 18)
or
(Region = "SE" and (RegionN between 1 and 29)
OR
(Region = "SW" and (RegionN between 1 and 29)

you can well see how much more easy our problem becomes when we split out
the post codes as above....

It is not clear if this data file of yours is being constantly updated.
further, are the post codes ALWAYS consistent in how they are entered (if
they are not..then trying to do processing on data that is not in your
example format is not going to work).

Anyway, the above is the general idea here. It is not known how large your
files are, but adding those two extra fields, and processing out the data
into those two fields would make this problem DRAMATICALLY easier. And, this
approach would also ensure good performance when building a query.

to do this type of data processing you are going to need some software
skills here. Lets take a crack at this...

The first routine we need is one that grabs the region value up to the first
number

The 2nd routine we need is one that grabs the region "number"

Here is the 3 routines needed. You can paste them into a standard code
module..and save it...

Public Function regionchar(s As Variant) As Variant

If IsNull(s) Then Exit Function

If s Like "[A-Z][A-Z]*" = True Then

regionchar = Left(s, 2)

Else

If s Like "[A-Z]*" = True Then
regionchar = Left(s, 1)
End If
End If

End Function
Public Function regioncharN(s As Variant) As Variant

If IsNull(s) Then Exit Function

If s Like "[A-Z][A-Z]*" = True Then

regioncharN = OnlyNumbers(Mid (s, 3))

Else

If s Like "[A-Z]*" = True Then
regioncharN = OnlyNumbers(Mid (s, 1))
End If
End If
End Function

Public Function OnlyNumbers(s As Variant) As String

Dim i As Integer
Dim mych As String

OnlyNumbers = ""

If IsNull(s) = False Then

i = 1
For i = 1 To Len(s)
mych = Mid$(s, i, 1)
If InStr("01234567 89", mych) 0 Then
OnlyNumbers = OnlyNumbers & mych
Else
Exit For
End If
Next i
End If
End Function

Now, it is just a simple matter to run two udpates on the file to set our
two new fields we created

Region (text)
RegionNum (number - integer)

update tblCustomers set Region = RegionChar([PostalCode]

Run the above in the query bulder...
and, also

update tblCustomers set RegionNum = RegionCharN([PostalCode]

Once we done the above, we can now build a query based on our conditions
quite easy.

Send this query results to a report, or even select, and cut/paste into your
word document....

and, you might find the formating in word works better if you export the
query to excel first...
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
Aug 4 '06 #6
I am having to interpret your partial example, because you didn't provide a
_definition_ of how zone and postal code are related. It's entirely possible
that my interpretation of your partial example was too simplistic and that
you may need to use a function to determine the zone.

But using the following SQL I put together (entirely in the Query Builder)
and some test data I concocted, with the following RecordSource for a Report
(with relatively little reformatting from the wizard's "tabular" report to
resize and reposition the text boxes, and to change their border from
transparent to solid), I created a report selecting specific people by
postcode that almost identically matches the template you posted.

And it was done entirely in Access.

Here's the SQL I used:

SELECT tblNameAndPostC odeBritish.Full Name, tblNameAndPostC odeBritish.Phon e,
tblNameAndPostC odeBritish.Addr ess, tblNameAndPostC odeBritish.Post Code,
tblNameAndPostC odeBritish.Obs FROM tblNameAndPostC odeBritish WHERE
(((Left([PostCode],2))="NW" Or (Left([PostCode],2))="WD")) OR
(((Left([PostCode],1))="N"));

You'll note I used "FullName" rather than "Name" because Name is an Access
reserved word and can lead to confusion.

Larry Linson
Microsoft Access MVP
"Julian" <x@x.xwrote in message news:4j******** ****@individual .net...
>It is relatively simple to include a Calculated Field in your Query that
returns a "sort order" value for the postal codes as you describe. It is
not clear to me exactly the order you desire, so I won't suggest a
particular algorithm, but you'll use embedded IIFs.

I would like to sort out customers by zones North, East etc, zones which
are
defined by various postcodes. For example the North zone would be defined
by
N(1-20), WD(1-24), NW(1-10). So, how do I make a query like: if the
customer's postcode starts with N(1-20), WD(1-24), NW(1-10), than sort
them
into the North zone customers. Then create a report with these customers
that looks like a table (the one with rows and columns and borders)
created
in Word, so I can print it. See what I mean at: ftp://87.112.95.111/
user: anonymous, no password.

>It is also not clear to me what your goal is for "(customers arranged
into
Word tables - normal tables, not database tables)." Unless you plan to
manually modify the output, there is not always an advantage in doing so.
I
>have not had exceptionally good luck with formatting being well-preserved
when I export Reports to "Word format" (actually RTF) and using COM
Automation to build Report output with Word can require a lot more work
than
>creating Access Reports.

If, however, you are going to create Access Reports, then you will use
the
Report's Sorting and Grouping properties to define the sorting and
grouping.

See above.

Julian


Aug 4 '06 #7

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

Similar topics

1
2597
by: MLH | last post by:
I have a challenge... In a table I call tblStuff4Letters with 3 fields: , and . I have a report called rptOutboundCorrespondence that feeds off this table. Sorting & grouping is turned on in that report - sorted first on (ascending) then on (ascending). Of course, there are more supporting fields in the table. The above 3 are the...
5
4103
by: Lapchien | last post by:
I have a field for a postcode. I'd like another field to auto contain an 'area' number, based on the first part (only) of the postcode. For example, if a postcode LS4 4DJ was entered, another field would read the LS4 part and enter '7' in that new field. I have a table that contains an up to date list of just these first-part postcodes......
3
2931
by: mark | last post by:
I have a table of UK companies whose records I want to filter using a map of postcode regions. For the benfit of people outside the UK, our postcodes are a pain to work with because they are not a standard length, and the part which identifies the region isn't a standard length either. The first letters of the postcode denotes a general...
0
4812
by: rmgalante | last post by:
Hi, I've been experimenting with the ASP.Net GridView and encountered some interesting issues that I thought I would share. I have a page that loads a GridView with a generic collection of objects. For the purposes of this discussion, the objects define a Customer, and have an id and a name. I want to sort these customers by id or by...
1
8420
by: Pacific Fox | last post by:
Hi all, I have a SQL statement that allows paging and dynamic sorting of the columns, but what I can't figure out without making the SQL a dynamic string and executing it, or duplicating the SQL statement between an IF and ELSE statement. Following is the SQL statement; set ANSI_NULLS ON
5
2341
by: billynastie2007 | last post by:
Hi i am writing a balloon race site and i am having problems with some functions to calculate the distance the balloon travels firstly i am reading my info from the database using the fetch assoc function what i have is 2 table one for the race details and one for the postcode details what i am having problems with is listing all the races in the...
5
1484
by: Paul Richardson | last post by:
Hi, What i'm trying to do is assign a class (i.e. UKPostCode) to a propety of the UKAddress Class. So for example: class UKAddress { public string AddressLine1
0
2015
by: Pinna | last post by:
Hiya, I am trying to select based on a range on postcode on a table. The field POSTCODE is a varchar2(8). The problem is when refinng on 'where postcode between 'PE1' and 'PE29'', because this is a character field and not a number field, 'PE3','PE4','PE5','PE6','PE7','PE8','PE9' are all ignored because the construct orders in characters and...
12
3515
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to print the report three times, but do not know how
0
7487
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...
0
7420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7446
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...
0
4966
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...
0
3476
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...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
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
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
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...

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.