A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Sorting A-Z



 
 
Thread Tools Display Modes
  #1  
Old October 11th, 2008, 06:00 PM posted to microsoft.public.access.tablesdbdesign
John
external usenet poster
 
Posts: 2,649
Default Sorting A-Z

Hi,

I have a Payment Method table with two fields (Payment ID, and Payment
Method).
In the Payment method I have cash, chase, visa, money order, american
express, western union, wire. These payment methods are text type, and they
are sorted alphabetically. I want to add another record "Other", and I want
to keep this always as the last option when creating a combo box in a form.
Currently it is sorting “other” along with the rest of the payment methods.
How can I make “other” appear at the bottom of the list? Thanks.

John

  #2  
Old October 11th, 2008, 07:48 PM posted to microsoft.public.access.tablesdbdesign
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Sorting A-Z

You can never rely on the order of records in tables: relational database
theory says that the DBMS is allowed to put the data wherever it wants to.
If the order of data is important, you must use a query with an appropriate
ORDER BY clause.

Assuming that you're using this for a combo box, you could make the
RowSource of the combo box something like:

SELECT PaymentID, PaymentMethod
FROM PaymentMethod
ORDER BY IIf([PaymentMethod] = "Other", "ZZZZ", [PaymentMethod])

Note that I removed the spaces in your field and table names. Spaces are
seldom a good idea.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"John" wrote in message
news
Hi,

I have a Payment Method table with two fields (Payment ID, and Payment
Method).
In the Payment method I have cash, chase, visa, money order, american
express, western union, wire. These payment methods are text type, and
they
are sorted alphabetically. I want to add another record "Other", and I
want
to keep this always as the last option when creating a combo box in a
form.
Currently it is sorting "other" along with the rest of the payment
methods.
How can I make "other" appear at the bottom of the list? Thanks.

John



  #3  
Old October 11th, 2008, 08:26 PM posted to microsoft.public.access.tablesdbdesign
John
external usenet poster
 
Posts: 2,649
Default Sorting A-Z

Hi Douglas,

Suppose my SQL is in the following format:

SELECT DISTINCTROW [Payment Methods].*
FROM [Payment Methods]
ORDER BY [Payment Methods].PaymentMethod;

How can I rewrite this to match your code below? Everytime I do that I get
syntax errors.

John

"Douglas J. Steele" wrote:

You can never rely on the order of records in tables: relational database
theory says that the DBMS is allowed to put the data wherever it wants to.
If the order of data is important, you must use a query with an appropriate
ORDER BY clause.

Assuming that you're using this for a combo box, you could make the
RowSource of the combo box something like:

SELECT PaymentID, PaymentMethod
FROM PaymentMethod
ORDER BY IIf([PaymentMethod] = "Other", "ZZZZ", [PaymentMethod])

Note that I removed the spaces in your field and table names. Spaces are
seldom a good idea.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"John" wrote in message
news
Hi,

I have a Payment Method table with two fields (Payment ID, and Payment
Method).
In the Payment method I have cash, chase, visa, money order, american
express, western union, wire. These payment methods are text type, and
they
are sorted alphabetically. I want to add another record "Other", and I
want
to keep this always as the last option when creating a combo box in a
form.
Currently it is sorting "other" along with the rest of the payment
methods.
How can I make "other" appear at the bottom of the list? Thanks.

John




  #4  
Old October 11th, 2008, 08:37 PM posted to microsoft.public.access.tablesdbdesign
John
external usenet poster
 
Posts: 2,649
Default Sorting A-Z

Douglas,

I got it to work. You're awsome.
Thank you so much!

John

"Douglas J. Steele" wrote:

You can never rely on the order of records in tables: relational database
theory says that the DBMS is allowed to put the data wherever it wants to.
If the order of data is important, you must use a query with an appropriate
ORDER BY clause.

Assuming that you're using this for a combo box, you could make the
RowSource of the combo box something like:

SELECT PaymentID, PaymentMethod
FROM PaymentMethod
ORDER BY IIf([PaymentMethod] = "Other", "ZZZZ", [PaymentMethod])

Note that I removed the spaces in your field and table names. Spaces are
seldom a good idea.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"John" wrote in message
news
Hi,

I have a Payment Method table with two fields (Payment ID, and Payment
Method).
In the Payment method I have cash, chase, visa, money order, american
express, western union, wire. These payment methods are text type, and
they
are sorted alphabetically. I want to add another record "Other", and I
want
to keep this always as the last option when creating a combo box in a
form.
Currently it is sorting "other" along with the rest of the payment
methods.
How can I make "other" appear at the bottom of the list? Thanks.

John




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:52 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 OfficeFrustration.
The comments are property of their posters.