Results 1 to 14 of 14
  1. #1
    crobaseball is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    128

    using the same field in a query but need different captions/headers

    So I'm using the same field in a query, price. But I need it listed twice in the table it creates, one as cogs_mfn, and the other as cogs_afn. The problem is that since the field that the data is coming from is exactly the same, the caption remains consistent, whether one or the other. I've tried to create separate expressions, but that doesn't work either. Anyone have any ideas? Thanks.

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    not quite sure why you are having a problem

    in the query grid

    Price1: Price..............Price2:Price

    or SQL

    SELECT.....Price as Price1, Price as Price2.................

  3. #3
    crobaseball is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    128
    When I run the query it then looks like this



    Not sure what to say, this is just how it's coming out. I'm rather surprised. I would have though it would have been fine.


  4. #4
    crobaseball is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    128
    Shoot, the pics didn't attach correctly. Here are the links . . . btw, what the heck am I doing wrong? I've used pixentral to embed pics of my screen shots in the past, but this is the 3rd time where they aren't uploading. Thoughts?

    http://www.pixentral.com/show.php?picture=1PvxOiqKH3dfvCqrUHjnSN1J6e4m3T0

    http://www.pixentral.com/show.php?pi...i5rJ6Hj73FjU20

  5. #5
    crobaseball is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    128
    Quote Originally Posted by Ajax View Post
    not quite sure why you are having a problem

    in the query grid

    Price1: Price..............Price2:Price

    or SQL

    SELECT.....Price as Price1, Price as Price2.................
    For anyone who has had a chance to review, this does not work.

  6. #6
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    this does not work
    Sorry to hear that - perhaps you can help me. I've got a form that doesn't work either - can you tell me why?

  7. #7
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Sorry, hadn't realised you have posted some images. I suspect if you look at the properties for the cogs_afn column in query design, you will see you have 'cogs_mfn' in the caption property

  8. #8
    crobaseball is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    128
    Quote Originally Posted by Ajax View Post
    Sorry, hadn't realised you have posted some images. I suspect if you look at the properties for the cogs_afn column in query design, you will see you have 'cogs_mfn' in the caption property
    There doesn't appear to be a way to do this in the query. Once you have a single field, it will always only show one caption, i.e. I don't know how you can make this unique. I tried to build the expression a number of different ways and none worked.

    But I figured out a workaround: create a subquery which builds the expressions separately, then use that subquery as part of your other query. It will allow for a second set of fields, with the exact same values/fields.

  9. #9
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    in query design, right click on the column and select properties and add a name under caption

    Click image for larger version. 

Name:	ScreenHunter_02 May. 26 18.39.jpg 
Views:	4 
Size:	49.9 KB 
ID:	20832

    then run the query
    Click image for larger version. 

Name:	Capture.JPG 
Views:	4 
Size:	16.8 KB 
ID:	20833

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    As Ajax demonstrated, can have as many aliases for the same field in query as you want. Don't understand why you want to.

    Why doesn't it work, what happens - error message, wrong results, nothing?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    or you may have set it in your table

    Click image for larger version. 

Name:	Capture.JPG 
Views:	4 
Size:	28.2 KB 
ID:	20834

  12. #12
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    can have as many aliases for the same field in query as you want. Don't understand why you want to.
    The problem is that in the query view the OP appears to have two different fields aliased with the same name - but in design view they are not aliased (and sql would not allow two fields to have the same alias anyway). I believe the issue is not with the sql code or aliasing, but what is displayed - i.e. using captions which I suspect the OP has set inadvertently or perhaps when designing his table copied a field (with a caption) to create a new field, changed the field name but forgot about the caption

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I never set Caption property (nor most other properties) in the table.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    nor do I - only causes confusion

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

Similar Threads

  1. Replies: 6
    Last Post: 10-05-2014, 07:23 PM
  2. Export to Excel displaying field names instead of captions
    By kattatonic1 in forum Import/Export Data
    Replies: 3
    Last Post: 04-10-2014, 09:13 AM
  3. Replies: 3
    Last Post: 03-04-2014, 12:35 PM
  4. Replies: 1
    Last Post: 03-17-2012, 08:49 PM
  5. Form-Query Variable line Headers
    By Cheshire101 in forum Forms
    Replies: 2
    Last Post: 09-13-2010, 12:38 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