Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2017
    Location
    Batley, United Kingdom
    Posts
    19

    Guidance Needed


    Hello all,

    I am fairly new to Access database design and looking for some guidance.

    I have designed a form that is for testing specification requirements. For example...

    I have a form that is asking for the following:

    Strength 1
    Strength 2
    Strength 3
    Strength 4
    AVG Strength (calculated field based on Strength 1-4)

    Which is all working as I want.

    What I am trying to do

    I want access to look at the AVG Strength field against another table for a specification for a particular Strength. If the AVG Strength passed the required criteria, I would like to display a PASS label on the form. If it fails the criteria check, I would like to display a FAILED label on the form.

    So, I guess there are two things I am look for help?

    1.) How to check against my specifications table and see if the AVG Strength passes or fails?

    2.) How to get a label to display depending on the outcome. (PASS / FAILED)

    The form is tided into a main table with lots of other columns which are not relevant at this time, the fields that are relevant would be:

    MAIN Table
    TestID
    Test Code
    Strength 1
    Strength 2
    Strength 3
    Strength 4
    AVG Strength (calculated field)
    SpecID (linked via relationships)

    SPECIFICATIONS Table
    SpecID (linked via relationships)
    TestCode
    Strength Specification

    So my idea if this....

    I enter my 4 strength values, access calculates the average of the 4 strengths tested. Once the average is calculated, I want access to check the specifications table based on the TestCode. If the TestCode entered on the form matches that of be in the Specifications table, look at the strength specification and whether it passes or fails display a corresponding label on the form. I would assume we would be using something like a vLookup or dLookup here? Just not sure where to start here....?

    How would I go about doing this? I am very new to the VBA programming side and not sure which route to take? Some guidance would be great. Thank you in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Since the tables can be joined on SpecID, create a query that joins them together and returns the desired fields. You can do the math in the query or on a form/report.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    Aug 2017
    Location
    Batley, United Kingdom
    Posts
    19
    Can you be a bit more specific on how to do this? How can I get the labels to display as well?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    In a new query field:

    PassFail: IIf([AVG Strength] >=[Strength Specification], "Pass", "Fail")

    Using your actual field names. By the way, spaces and symbols in field names are more trouble than they're worth in the long run.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Join Date
    Aug 2017
    Location
    Batley, United Kingdom
    Posts
    19
    Thanks for the response once again. First off, let me let you that I do actually name my fields as such... Example: ID, FirstName, LastName, Email, PhoneNo, etc... I never use spaces or underscores.

    Anyway, I am a bit confused as to how things will work. I guess the bigger picture is this...

    Testing different yarn strengths from different suppliers. There is a table that contains all of the YarnCode and Strength specifications for all the different yarns.

    Then the main table is what captures the yarn strength data and does the AVGStrength calculation. Once the average is calculated. The user also puts in the YarnCode which needs to check the other table for that YarnCode and then compare the Specification with the AVGStrength allowing for +/- 5% difference to the Specification.

    If the yarn AVGStrength passes, then display a message on the form that says 'PASS' but obviously if it fails then "FAILED' displays.

    I am sort of lost as to where I need to do these things? Hoping for more in-depth of an explanation or even point me to resources I can read / watch that explain these things.

    I can set up tables and relationships, create basic queries, forms and reports. I am just entering the more complex side of things and need some direction.

    So anyone that could help with this would be great. Thanks again.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Have you used VBA code? It sounds like you need to do this test at some point during data entry, tied either to a button or the after update event of a textbox. You can use DLookup() to get the specification.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Join Date
    Aug 2017
    Location
    Batley, United Kingdom
    Posts
    19
    I'm just getting involved in VBA and coding actions etc. Hence this post. Just looking for guidance and direction.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If the fields are both on the form, a textbox control source like:

    IIf([AVG Strength] >=[Strength Specification], "Pass", "Fail")

    If you wanted to do it in a specific event, the VBA would look like:

    Code:
    If Me.AvgStrength >= DLookup(...) Then
      Me.LabelName.Caption = "Pass"
    Else
      Me.LabelName.Caption = "Fail"
    End If
    That further assumes you need to look up the specification.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Dsproductions: Could be done without vba but I think one of the textboxes would have a convoluted expression with nested IIF statements since it's not a simple matter of being >= . That is, I see you have a 'between' situation with a 5% variance. If I may borrow from pbaldy, I think you might need something like

    Code:
    Dim dblAvg As Double, dblSpec As Double
    dblSpec = DLookup(...)
    dblAvg = Me.AvgStrength
    
    If dblAvg >= (dblSpec * .95) And dblAvg <= (dbSpec * 1.05)
      Me.LabelName.Caption = "Pass"
    Else
      Me.LabelName.Caption = "Fail"
    End If
    By the time you read this, I will likely be unavailable for a few days.
    Last edited by Micron; 08-20-2017 at 09:04 PM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Need guidance on something that seems simple
    By Locke_Valken in forum Access
    Replies: 17
    Last Post: 09-02-2016, 11:01 AM
  2. Need a bit of guidance
    By pipermac in forum Access
    Replies: 3
    Last Post: 10-14-2014, 08:18 AM
  3. Help needed : Library catalogue in access format is needed
    By dealers in forum Sample Databases
    Replies: 3
    Last Post: 01-16-2014, 02:03 PM
  4. Some Combo Box Guidance
    By herbc0704 in forum Forms
    Replies: 1
    Last Post: 11-11-2011, 01:15 PM
  5. Need guidance on database
    By yak600 in forum Access
    Replies: 0
    Last Post: 08-04-2009, 07:46 AM

Tags for this Thread

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