Results 1 to 8 of 8
  1. #1
    darlaj5 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2011
    Posts
    10

    Sorting two fields

    If I have two fields 1-pick up times and 2- drop off times is there a way I can sort the page by time combining the two fields?

    Thank you for your time

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You could but would the result make sense? Why are you wanting to do this, what is it you need to accomplish?

  3. #3
    darlaj5 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2011
    Posts
    10
    Because sometmes a drop off occurs during a pick up schedule so i have to sort the table by times but the pick up times and drop off times are two seperate fields. I need to sort the page by time or combine the two fields when setting the sort command.

    Is there a way can you help? Thank you for your time.

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    You will need to create two queries. First one will have only pickup time field. Create an alias for the field, ie. SchedTime: PickUp

    The second one will have only drop off time field. Create an alias for this field also. It needs to be the same as the first, ie. SchedTime: DropOff

    Save both queries. Now create a Union query of the two queries you created and the information will be in one query. You can add an Order By clause at the end of the second part of the Union, ie. Order By SchedTime (ascending)

    Alan

  5. #5
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Hi,

    I haven't fully thought this out but what about having a separate table where there is only one time for each transaction. The part I haven't thought out is whether to have another field in the new 'Time' table that codes the time as a pick-up or drop off or whether the original table should have the pick-up/drop off code fields.

    Does the time include the date? If not then you might want to date stamp each new 'Time' record (additional field) so you can limit the query returns to a certain day or days if desired.

  6. #6
    darlaj5 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2011
    Posts
    10
    Thank you both for your help this will really help. The only thing is how do you create a alias? I'm new to this and self taught and I really appreciate your help. Is there an advanced tutorial for access?

    Also do I have to change the fields in the table to reflect the above mentioned field names?

    Again thank you.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2007
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    An alias field is a field constructed with an expression, usually to manipulate data with a calculation to create new value. Example would be - Age: DateDiff("yyyy",[BirthDate],Date()). You would type this entire expression in the Field row of Query Designer. If you forget Age: then Access will use something like Expr1: for you. Alansidman's suggestion is a way to get these time values into a common field named SchedTime. In this case the expression is simply a reference to existing fieldname, no calculations taking place.
    Access Help has more info, search 'select query'.

    However, I think might be able to do the UNION on the tables without the intermediate queries. There is no wizard or designer for UNION queries, must type into the SQL View window of Query Designer. Something like:

    SELECT ID, "Pickup" As Type, PickupTime As SchedTime FROM tblPickup
    UNION SELECT ID, "DropOff", DropoffTime FROM tblDrop;

    This is really how the table structure should be to begin with.

    Something to be aware of about UNION, it will not show multiple identical records.

    Tutorials are all over the place, start at http://office.microsoft.com/en-us/tr...010158283.aspx
    and http://www.techonthenet.com/sql/union.php

  8. #8
    darlaj5 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2011
    Posts
    10
    Thanks Adam I appreciate your input. This data base I'm trying to put together is actually only a small piece of the pie to eliminate redundant tasks. We use School Master for our transportation needs. I'm creating this data base to minimize the users on School Master. Its complicated and I'm sure difficult to relate to, never the less it will satisfy our needs. I think I'm just challenged and determined to understand this program. I have actually set up the data base and it works and serves the purpose now. THe only thing I haven't put together yet is the sorting but based on the info above I'm sure it will come together. If not I'll just run one report for pu and one for do. Thank you to all for you input I love this site. I'm going to take the tutorials and learn this program. Thanks for the link, I'm obsessed with this access now, lol. Thsi post is for both of my threads....

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

Similar Threads

  1. Sorting
    By BorisGomel in forum Access
    Replies: 0
    Last Post: 04-25-2011, 11:22 AM
  2. Sorting and Grouping
    By mduplantis in forum Queries
    Replies: 3
    Last Post: 07-29-2010, 12:31 PM
  3. Sorting Records
    By sfoot0309 in forum Reports
    Replies: 1
    Last Post: 02-05-2010, 05:50 PM
  4. Need Sorting Help
    By rbpd5015 in forum Access
    Replies: 1
    Last Post: 09-28-2009, 07:39 PM
  5. Sorting in a subform
    By hraup in forum Forms
    Replies: 2
    Last Post: 08-29-2006, 12:35 PM

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