Results 1 to 11 of 11
  1. #1
    aselm01 is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2012
    Location
    So Cal
    Posts
    29

    Display Pass or Fail based on number range

    I have a form for entering data on voltage measurements for a circuit card. For each field of entered data I have a Pass/Fail field that I currently enter manually. What I want to do is automate this so that if I enter a voltage value that is inside a certain range then the form checks it and returns a Pass or Fail in the next field. This will also have to be saved into the table that the data is going into.

    Here is an example of the range I would need to check against: +4.900Vdc to +5.100Vdc, anything within is pass anything above or below is a fail. The same would have to work for a negative value such as -15.75 to -14.75. For positive numbers the sign is not needed, but I would like to be able to include the negative sign if possible. The sign is not that big a deal to keep if it really complicates things.

    Does the field in the table this would be stored in need to be a specific type like "Yes/No"? Or can it be a text field?

    The Table name is TBL_IO, the first of the field names for this are "P5Vdc_IO_PWA" (number field, this is where the value will be stored), "P5Vdc_IO_PWA_PF" (text field, this is where I would store the Pass/Fail). The field names are similar for another 15 fields and so I would have to repeat this for all.



    For any who try to help Thanks in advance!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    Probably should not actually save the pass/fail. Storing calculated data is usually bad idea. Calculate when needed. An IIf expression in query or textbox should serve. Try:

    IIf([fieldname] BETWEEN 4.9 AND 5.1 OR BETWEEN -15.75 AND -14.75, "Pass", "Fail")

    BETWEEN AND operator is inclusive for the range ends.
    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.

  3. #3
    aselm01 is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2012
    Location
    So Cal
    Posts
    29
    Quote Originally Posted by June7 View Post
    Probably should not actually save the pass/fail. Storing calculated data is usually bad idea. Calculate when needed. An IIf expression in query or textbox should serve. Try:

    IIf([fieldname] BETWEEN 4.9 AND 5.1 OR BETWEEN -15.75 AND -14.75, "Pass", "Fail")

    BETWEEN AND operator is inclusive for the range ends.
    I received a syntax error when trying it in a query and it just did not work when I put it in the field I want it to go in.

    Here is the db so you can see my forms that I am using. Right now I am using list boxes for selecting pass or fail. Ultimately I would like the form to be auto matic so that when I enter the data it places a green PASS or a Red Fail in the pass/fail field.

    As far as storing goes how do you get it to show up on a report? Use the query field in the report design?

    Tony
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    Sorry, slight error in suggested expression:

    PF: IIf([P5Vdc_IO_PWA] Between 4.9 And 5.1 Or [P5Vdc_IO_PWA] Between -15.75 And -14.75, "PASS", "FAIL")


    Use textbox Conditional Format to get the colored text.

    Bind textbox to the query field or do the same calc in textbox on report.
    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.

  5. #5
    aselm01 is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2012
    Location
    So Cal
    Posts
    29
    Quote Originally Posted by June7 View Post
    Expression works for me in my db.

    I don't see a table named TBL_IO. Did you mean TBL_AIO?

    Which objects are involved in this issue? Where did you attempt the calc?


    Use textbox Conditional Format to get the colored text.

    Bind textbox to the query field or do the same calc in textbox on report.
    Sorry, yes it should be AIO. I created a blank query and added table "TBL_AIO". Then chose the field "P5Vdc_IO_PWA_PF" and put your string in the criteria field and tried to run the query. That is where I got the error. I want the above field to show Pass or Fail for the field "P5Vdc_IO_PWA".

    All three tables (TBL_AIO, TBL_SLD, & TBL_Fog) will have the same type of Pass/Fail field so this will be a global thing. Also what type of field should they be to make this work?

    As far as the color and a textbox how will that work with the above on the form?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    I edited my post while you were posting. I found the table and tested expression in a query. The revised expression does work.

    PF: IIf([P5Vdc_IO_PWA] Between 4.9 And 5.1 Or [P5Vdc_IO_PWA] Between -15.75 And -14.75, "PASS", "FAIL")
    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.

  7. #7
    aselm01 is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2012
    Location
    So Cal
    Posts
    29
    Quote Originally Posted by June7 View Post
    I edited my post while you were posting. I found the table and tested expression in a query. The revised expression does work.

    PF: IIf([P5Vdc_IO_PWA] Between 4.9 And 5.1 Or [P5Vdc_IO_PWA] Between -15.75 And -14.75, "PASS", "FAIL")
    I created a new query, based on TBL_AIO, selected the field P5Vdc_IO_PWA_PF, and put the following string, IIf([P5Vdc_IO_PWA] Between 4.9 And 5.1, "Pass", "Fail") into the criteria box and it works now. So I don't know what I was doing wrong. Because it looked the same the last time and I got a mismatch error.

    Thanks!

    Now to try the color code thing...

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,953
    Textbox Conditional Formatting is on the Design tab.

    If these 3 tables all have the same kind of data and essentially the same fields, why not one 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.

  9. #9
    aselm01 is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2012
    Location
    So Cal
    Posts
    29
    Quote Originally Posted by June7 View Post
    Textbox Conditional Formatting is on the Design tab.

    If these 3 tables all have the same kind of data and essentially the same fields, why not one table?
    I wanted to keep them separate in case I needed to do some stuff later on.

    On the query Pass/Fail thing. It looks like I was premature. I blanked out the pass/fail entries in the table and tried the query and it did not work. It just returned blank fields when ran. I don't know what I am doing wrong. Here is a picture of what the query looks like for just the first two fields I am working on.

    Click image for larger version. 

Name:	db query.jpg 
Views:	7 
Size:	65.3 KB 
ID:	13707

  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,953
    The expression goes on the Field line. The expression will create a field with values of either Pass or Fail. Then you can apply criteria to the constructed field like:

    = "Pass"

    or

    = "Fail"

    By calculating the Pass/Fail value the _PF fields are not needed in table. Don't have to rely on users to input the Pass/Fail. The query calc provides the value. This is 'automation'.
    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
    aselm01 is offline Novice
    Windows 8 Access 2013
    Join Date
    Jun 2012
    Location
    So Cal
    Posts
    29

    Wink

    Quote Originally Posted by June7 View Post
    The expression goes on the Field line. The expression will create a field with values of either Pass or Fail. Then you can apply criteria to the constructed field like:

    = "Pass"

    or

    = "Fail"

    By calculating the Pass/Fail value the _PF fields are not needed in table. Don't have to rely on users to input the Pass/Fail. The query calc provides the value. This is 'automation'.
    Okay I just tested it again and this time I played with the values and it worked as it should. I was putting the string in the wrong place every time. Now I can go and remove those fields for pass/fail in the tables. As you said they are no longer needed.

    Now I will also work on the color code thing.

    Thanks again June7!

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

Similar Threads

  1. Image controls fail to display
    By GraeagleBill in forum Reports
    Replies: 5
    Last Post: 09-06-2012, 12:28 PM
  2. Replies: 28
    Last Post: 04-24-2012, 10:14 PM
  3. Replies: 2
    Last Post: 04-16-2012, 12:56 PM
  4. Replies: 6
    Last Post: 07-25-2011, 01:54 PM
  5. Display PASS or FAIL using Unbound textbox
    By Shambler2 in forum Reports
    Replies: 7
    Last Post: 06-02-2011, 11:19 AM

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