Results 1 to 13 of 13
  1. #1
    pharmacologist is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    39

    Access query with expression not showing up in Excel Get Data, workaround?


    It seems having an expression in my access query prevents me from using it with Get Data in Excel. Is there a workaround for this?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    I presume you mean the excel ribbon functionality (Data>From Access) so maybe, maybe not. No information to go on. Would help if you clarified the detail - the actual error message and sql to the query would be a good start.

  3. #3
    pharmacologist is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    39
    There is no error message. The query runs fine in Access. It does not show up as a query in Excel in the Data>From Access when I load the database. Removing the expressions allows it to appear. Creating separate queries with the expressions and then including them in another query does not work.

    query
    Code:
    SELECT Inventory.SampleID, Sum(voltaken([Inventory].[SampleID],[Plates].[Reagents],[Inventory].[Molarity])) AS Used, Chemicals.Abbreviation, Chemicals.MW, Chemicals.Radionuclide, Inventory.[Volume Prepared], Nz([BoxID]) AS Expr1, Boxes.Label, [Shelf] & "." & [Rack] & "." & [Tray] & "." & [Position] AS Address, Inventory.[Reference Date], Inventory.[Date Prepared], Inventory.Retired, Chemicals.Compound, Chemicals.ChemIDFROM Plates, Chemicals INNER JOIN ((calcinvused INNER JOIN Inventory ON calcinvused.SampleID = Inventory.SampleID) INNER JOIN Boxes ON Inventory.Box = Boxes.BoxID) ON Chemicals.ChemID = Inventory.ChemID
    GROUP BY Inventory.SampleID, Chemicals.Abbreviation, Chemicals.MW, Chemicals.Radionuclide, Inventory.[Volume Prepared], Nz([BoxID]), Boxes.Label, [Shelf] & "." & [Rack] & "." & [Tray] & "." & [Position], Inventory.[Reference Date], Inventory.[Date Prepared], Inventory.Retired, Chemicals.Compound, Chemicals.ChemID;

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    are you referring to the nz function? nz is a vba function specific to access but not recognised in excel vba

    in this instance do you need it anyway? If to supply 0 then change to

    iif(isnull(BoxID),0,BoxID)

  5. #5
    pharmacologist is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    39
    No, sorry, that was an attempt at another possible solution I was trying

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    so what is your expression/s you take out for it to work?

  7. #7
    pharmacologist is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    39
    Might have changed a bit from before as I'm still fussing with it.. this one doesn't show up:

    Code:
    SELECT inventory.sampleid,
    chemicals.abbreviation,
    chemicals.mw,
    chemicals.radionuclide,
    inventory.[Volume Prepared],
    boxes.label,
    inventory.[Reference Date],
    inventory.[Date Prepared],
    inventory.retired,
    chemicals.compound,
    chemicals.chemid,
    Sum(Voltaken([Inventory].[SampleID],[Plates].[Reagents],[Inventory].[Molarity])) AS used,
    [Shelf]&"."&[Rack]&"."&[Tray]&"."&[Position] AS addressfromplates,
    chemicals
    INNER JOIN ((calcinvused
    INNER JOIN inventory
    ON calcinvused.sampleid=inventory.sampleid)
    INNER JOIN boxes
    ON inventory.box=boxes.boxid)
    ON chemicals.chemid=inventory.chemid
    GROUP BY inventory.sampleid,
    chemicals.abbreviation,
    chemicals.mw,
    chemicals.radionuclide,
    inventory.[Volume Prepared],
    boxes.label,
    inventory.[Reference Date],
    inventory.[Date Prepared],
    inventory.retired,
    chemicals.compound,
    chemicals.chemid,
    [Shelf]&"."&[Rack]&"."&[Tray]&"."&[Position],
    boxes.boxid;
    This one shows up after removing the two fields that are calculated:

    Code:
    SELECT inventory.sampleid,
    chemicals.abbreviation,
    chemicals.mw,
    chemicals.radionuclide,
    inventory.[Volume Prepared],
    boxes.label,
    inventory.[Reference Date],
    inventory.[Date Prepared],
    inventory.retired,
    chemicals.compound,
    chemicals.chemidfromplates,
    chemicals
    INNER JOIN (inventory
    INNER JOIN boxes
    ON inventory.box=boxes.boxid)
    ON chemicals.chemid=inventory.chemid
    GROUP BY inventory.sampleid,
    chemicals.abbreviation,
    chemicals.mw,
    chemicals.radionuclide,
    inventory.[Volume Prepared],
    boxes.label,
    inventory.[Reference Date],
    inventory.[Date Prepared],
    inventory.retired,
    chemicals.compound,
    chemicals.chemid,
    boxes.boxid;
    edited to make the queries more readable, but then it messed up the spacing. these queries do work, spacing problems are not in the original

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    so voltaken is a UDF (user defined function) - again that won't be recognised in Excel because it is not in excel. I've never tried it but all I can suggest is copy the function to excel as a public function. It might work, but very much depends on what it actually does.

  9. #9
    pharmacologist is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    39
    Yeah I'd already tried that and it didn't work. Thanks though

  10. #10
    pharmacologist is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    39
    Searching for access query UDF excel is now getting me results that are more in the right direction and it seems like it's not possible to pull these queries in due to built-in security limitations..

  11. #11
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    perhaps - but I think it is more to do with you using functions not recognised by Excel.

  12. #12
    pharmacologist is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    39
    Yeah I don't know that's why I'm here. For now I'm just creating a table from the query in access and pulling that to Excel but I'll have to be updating it unless there's a way to automate that?

  13. #13
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    but I'll have to be updating it unless there's a way to automate that?
    please clarify what that means - automate what? generation of a table? if so, from where? at what point? using what?

    Your questions are vague and require many posts to try to determine what you mean? Please describe clearly what you are trying to do and why you are doing it rather than focussing on how you are doing it.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-31-2016, 04:28 PM
  2. Access-->Excel Connect, Query not Showing on list
    By jurbin in forum Import/Export Data
    Replies: 4
    Last Post: 03-06-2014, 04:25 PM
  3. Replies: 1
    Last Post: 11-21-2013, 10:28 AM
  4. Import access query data into excel file, using excel vba
    By exceljockey in forum Import/Export Data
    Replies: 3
    Last Post: 11-15-2013, 02:36 PM
  5. Replies: 4
    Last Post: 05-17-2013, 04:00 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