Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Peakwalker is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    14
    SampleDatabase.zip



    I've never attached anything before, I hope this has worked.

    My description of the file and queries:

    The table _Assay contains a sample number, with data CU_A1 and CU_A2. The CU_PLOT field merges the two, as data from CU_A2 is used preferentially over CU_A1.
    The table _Assay_Standards is the same but does not have the same combined plot field. However data from A2 is still used preferentially over A1.
    Note for both tables there are only three decimal places for each value. There are also null values in each table, which happens as we use different assay methods, different labs, etc.
    It is important that the assay and standards tables remain separate, but they do at times need to be reviewed together. To accomplish this, I’ve created a joined table, lut_master_sample_number_list, which combines the sample numbers from both the assay and standards tables into one.
    Then, all three tables are used within the lut_master_assay_data table, which is meant to show all sample numbers, and their preferred values, as one.
    I’ve done a few different queries to try and figure out the issue.
    CU 1 shows how the data looks on its own, without me specifying the number of decimal places, rounding, currency, etc. As you can see, it displays as a float with many decimal places.
    CU 2 is exactly the same but adding the round function. No change.
    CU 3 is the same as two but I have specified zero decimal places to round to. Although it won’t round to 3 in CU 2, it will round to zero places in this example.
    CU 4 shows the same as CU 2 but with the CCur function added. Now the data is displaying correctly to three decimal places, but I get a #error for all null values. Note the round function works as you would expect in this example, if you change it to two decimal places, then it only shows 2.
    CU 5 is the same as CU 1 again, but in the property sheet, I have specified that the format is fixed, with 3 decimal places. In this case it visually seems to display correctly, but if you click on a cell, the data is all still there.
    CU 6 is the same as CU 5 but with the round function added. So it is fixed at 3, and rounded to 3, but again, if you click on a cell, there are still many sig figs.
    CU 7 has your solution of using the IsNull function.
    CU 8 is the same as CU 7 but with rounding. No change.
    CU 9 is the same as CU 8 but changed to currency. Same result as CU4, correct decimal places, but error message showing.
    The final answer should be the values as displayed in CU 4 and CU 9 but without any #error messages in the null fields. They should still remain blank like all the other examples.

  2. #17
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    That is odd. I don't think I have seen that before.
    I never really use the Switch function, so perhaps that is part of the cause of the issue. It does say that Switch returns a Variant value.

    Maybe try creating a User Defined Function instead to do your calculation. Perhaps that will work?

  3. #18
    Peakwalker is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    14
    Thanks for looking at it, you can see why I got stumped!

    I'm not sure how to do user defined functions, and really, although frustrating and annoying, it's not like I can't still do my work. I'll leave this as being unsolved, maybe someone else wants to play with it in the future.

  4. #19
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Yes, sorry I couldn't be of more help. Hopefully, someone else will have some ideas.

  5. #20
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Does this get you what you want:

    SELECT lut_master_sample_number_list.SAMPLE_NO, Val(Nz([_Assay_Standards]![CU_A2],Nz([_Assay_Standards]![CU_A1],Nz([_Assay]![CU_PLOT],0)))) AS [CU10], IIf([CU10]=0,Null,[CU10]) AS [CU10Adj]
    FROM (lut_master_sample_number_list LEFT JOIN _ASSAY ON lut_master_sample_number_list.SAMPLE_NO = [_ASSAY].SAMPLE_NO) LEFT JOIN _ASSAY_STANDARDS ON lut_master_sample_number_list.SAMPLE_NO = [_ASSAY_STANDARDS].SAMPLE_NUMBER;


    BTW, several fields are set to display 4 decimals. I seldom bother with format settings in tables.
    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.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 07-28-2012, 03:55 AM
  2. Only show numeric values
    By dr4ke in forum Queries
    Replies: 2
    Last Post: 07-22-2012, 05:09 AM
  3. formatting a text box to show all data
    By mejia.j88 in forum Reports
    Replies: 8
    Last Post: 03-02-2012, 10:10 AM
  4. Replies: 5
    Last Post: 12-10-2011, 11:49 AM
  5. Formatting a Calculated Field
    By e_lady333 in forum Queries
    Replies: 0
    Last Post: 03-17-2010, 06:11 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