• Three Simple Questions for a Select Query

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Three Simple Questions for a Select Query

    Author
    Topic
    #1773634

    I’m making a new query from one of my old ones. It’s cool that you can copy and paste the old one, rename the pasted one, then modify it to your new needs. I’m a bit pleased with myself that I can handle a lot of this stuff in spite of not having worked with Access for quite a while. But I need help with three things:

    1. I’ve rearranged the order of some fields, to put them in the proper place when I export the new query to Excel. Here’s the order I want:

    But when I run the query, they come out in a different order:

    When I download the query to Excel, they download in the sequence to which I reordered them (the top one above). This is confusing. How do I fix it?

    2. The ServiceClass field contains one of two values: “Enlisted” or “Officer”. I want to create a calculated field that contains “Off” if Service Class contains “Officer”, and is blank otherwise. What’s the code to put into the calculated field?

    [INDENT]Found it myself! It is…
    Officer: IIf([ServiceClass]=”Officer”,”Off”,””)[/INDENT]

    3. The query contains two address fields: Address and Address2 (name truncated in the second image above). Only a few records have an entry in Address2. I want to combine these two fields in a calculated field in the new query. I COULD just do it by putting a space between them. That would be simple, but tacky. I’d much rather do it by putting a comma and space after Address, but only if there is an entry in Address2. What’s the code to put into the calculated field?

    Reply To: Three Simple Questions for a Select Query

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: