Results 1 to 7 of 7
  1. #1
    SiyarK is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    4

    Unable to sort records in database

    Hello everyone! Let me first introduce myself, I am SiyarK and have just registered to this forum. I am a beginner with Microsoft Access so please bear with me I have a little challenge for which I haven't been able to find a solution...


    I have made a database for the start-up company where I'm doing my internship at; a database with (potential) customers and competitors. It's a split form so there is a table on the bottom of the screen with all the records. (see attachment)


    And now we arrive at the problem. I want to be able to sort the companies according to company type, product, status etc. But I am not able to do that. On the other hand, I am able to sort the company names in an alphabetical order. For the record: the boxes for type/product/status/competitor are combo boxes, you can only select one of the options and not type in it.


    Could someone please tell me how to sort these companies according to type/product/status/competitor? Many thanks in advance!


    And oh yeah, nevermind the query on the left, it's empty. Haven't used a query for this form.




    SiyarK

    Click image for larger version. 

Name:	company database.jpg 
Views:	9 
Size:	84.7 KB 
ID:	11067

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I want to be able to sort the companies according to company type, product, status e
    Haven't used a query for this form.
    The form record source should be a query. In a query, you can use the ORDER BY clause to sort on multiple fields. If the record source is a table, you can only sort on one field using the ASC/DESC buttons on the tool bar.

  3. #3
    SiyarK is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    4
    Quote Originally Posted by ssanfu View Post
    The form record source should be a query. In a query, you can use the ORDER BY clause to sort on multiple fields. If the record source is a table, you can only sort on one field using the ASC/DESC buttons on the tool bar.
    Thanks ssanfu for replying on such a short notice!

    The strange thing is that even though my record source is a table, I can only sort the field with the company names with the ASC/DESC buttons. But you're probably right, a query would make life easier. So I've tried to make one but it doesn't really work.
    Click image for larger version. 

Name:	Attachment 1.jpg 
Views:	6 
Size:	87.9 KB 
ID:	11071

    Because the type/competitor/products/status are numerical values in the ''Company table'', I've made separate tables for each one of them so the database would know that if Company A is Type 1, that it should show Pharmaceutical in the records (instead of 1), and if Company B is Type 2, that it would show Biotechnology in the records, etc... Therefore I also made a ''Connection table'' so the database would understand these relationships. But when I run the query, the fields are still empty

    Click image for larger version. 

Name:	Attachment 2.jpg 
Views:	6 
Size:	73.4 KB 
ID:	11069

    What am I doing wrong?
    Last edited by SiyarK; 02-06-2013 at 03:24 AM. Reason: something wrong with the image

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    "Type" is a reserved word in Access and shouldn't be used for object names. You have "Type" as a field in the Company table and as a table name and as a field name in table "Type". Here is a list of reserved words: http://allenbrowne.com/AppIssueBadWord.html
    Also, it is better to not use spaces in object names.

    I think it is your join types. Since every field in "Connection table" is a foreign key, every field needs to have data. In design view, open the properties for each join and select the 3rd option (I think):

    "Select All records from 'Connection table' and only those records from 'XXXX' where the joined fields are equal". ("XXXX" would be the different table names.)

  5. #5
    SiyarK is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    4

    Post

    Quote Originally Posted by ssanfu View Post
    "Type" is a reserved word in Access and shouldn't be used for object names. You have "Type" as a field in the Company table and as a table name and as a field name in table "Type". Here is a list of reserved words: http://allenbrowne.com/AppIssueBadWord.html
    Also, it is better to not use spaces in object names.

    I think it is your join types. Since every field in "Connection table" is a foreign key, every field needs to have data. In design view, open the properties for each join and select the 3rd option (I think):

    "Select All records from 'Connection table' and only those records from 'XXXX' where the joined fields are equal". ("XXXX" would be the different table names.)
    No it works just fine, I now know what the mistake was First of all, in the company table the type/sector/etc were text values instead of numerical. So when building relations I could not connect the TypeID to Type (I was making a one-to-many relation from my Company Table). So I got that sorted out. Also, in the advanced option I changed the ''Defaul record locking'' to ''No locks''.

    That has solved it all! So I've got a nice, functional query in my database!

    Still, many thanks for you help ssanfu!

  6. #6
    SiyarK is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    4
    I have solved it!

    First of all, in the ''Company table'', type/product/competitor etc.. were text values. therefore, I had a mismatch when I wanted to make a one-to-many relation and couple for example TypeID to Type. I have changed it to numerical values, so the relations are fine now. I'm not using the connection table anymore, because I don't need to.

    And also, in the advanced options I have changed ''Default record locking'' to ''No locks''. Now my query works fine and I can sort everything the way I want!!

    Thanks for all the help ssanfu ;-)
    Last edited by SiyarK; 02-07-2013 at 09:12 AM.

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Wonderful. Glad to be of help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 01-05-2012, 11:52 AM
  2. unable to sort
    By Cparks in forum Access
    Replies: 3
    Last Post: 10-31-2011, 12:58 PM
  3. Unable to open front end of split database
    By Dunro in forum Import/Export Data
    Replies: 10
    Last Post: 09-17-2011, 07:37 AM
  4. Replies: 1
    Last Post: 11-17-2010, 10:38 AM
  5. Replies: 2
    Last Post: 11-05-2010, 04:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums