Results 1 to 8 of 8
  1. #1
    Shambler2 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Location
    Perris, CA
    Posts
    11

    Exclamation Unbound textbox and report linked to vba

    Help please. I have coding that looks like this and does nothing. Yet how it is worded I need to work. I just want the text box to display text stating PASS in green text or FAIL in red text based on the output of the values in which the report is created.

    There are no errors in my code, but it does nothing. Perhaps you can make it work or have another design?

    Private Sub Passit(Passit As Integer)

    For Passit = 0 To 60 Step 15
    If [OvenTemperatureValues]![Pass/Fail] = "Pass" Then
    Next
    If Passit = 60 Then

    ForeColor.TextBox = Green
    Me.Text50 = "PASS"
    Else
    ForeColor.TextBox = Red
    Me.Text50 = "FAIL"

    End Sub

    I need to state pass if 10 temperature sensors reach 170 degrees for one hour time. Since I cannot figure that part out, I created a field that check if all sensors reach 170. That is the PASS/FAIL field. Since my records are in 15 minute increments, I have it count to 60 (One hour) to see if it reached temp for one hour. Make sense? The report is generated from a form which a user states the start date/time and the end date/time.

    OvenTemperatureValues is the query I used to create report, and Pass/Fail is a field I created to check all sensors reach temp. I just need help verifying they stayed for one hours time.

    Thanks to all the VBA masters!

    Greg

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Hi

    For Passit = 0 To 60 Step 15
    If [OvenTemperatureValues]![Pass/Fail] = "Pass" Then
    Next
    I don't understand what this is doing.
    I could be wrong but it seens to me that this for/next loop just keeps on looking at the same control (I assume it's a textbox) to see if it = "Pass"

    Can you explain what you think it does
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Shambler2 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Location
    Perris, CA
    Posts
    11
    Bob,

    I have a report that is created from a query. The querys is displaying a date/time field with 15 minute intervals and 10 temperature sensor readings. My goal is for the report to display GREEN text stating "PASS" or red text stating "FAIL" if certain conditions are not met.

    The conditions are: all 10 sensors reach 170 degrees over 1 hours time at any point in the query. A form is used to generate the report based on user start and end date/times. Make sense? So on the query I created a Pass/Fail field to display if all sensors reached 170 or greater for that particular timestamp. But I do not know how to check if it stayed that temp for over 1 hour.

    I have another post that elaborates more detail in this forumn for the same problem.
    https://www.accessforums.net/reports/display-pass-fail-using-unbound-textbox-13994-newpost.html

    This will show you more what I'm trying to do. Thank you so much. I'm at a brick wall for what seems such an EASY task.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Hi

    To help me understand a little more of what you are trying to do please answer these questions.

    You posted the following code:
    Code:
     
    Private Sub Passit(Passit As Integer)
     
    For Passit = 0 To 60 Step 15
    If [OvenTemperatureValues]![Pass/Fail] = "Pass" Then
    Next
    If Passit = 60 Then
     
    ForeColor.TextBox = Green
    Me.Text50 = "PASS"
    Else
    ForeColor.TextBox = Red
    Me.Text50 = "FAIL"
     
    End Sub
    Where is this code? (Form Module, Report Module or General Module)

    In the following line of code:
    If [OvenTemperatureValues]![Pass/Fail] = "Pass" Then
    Is [Pass/Fail] the name of a control on a form or report and if so, what sort of control is it? A textbox perhaps?

    What is [OvenTemperatureValues] ?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Shambler2 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Location
    Perris, CA
    Posts
    11
    Bob,
    I'm sorry. I'm still learning this. I created a unbound textbox in design mode of the report. Then I did build event and code. Its on the report itself. I just basically took the for statement and tried to plug in values from what I thought I understood from snooping around online. But honestly, any other way you see that I could do this would be awesome. I just thought code on the report would be easy to just compare the pass/fail field I created to the timestamp field.

    Thanks,
    Greg

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Can you post the SQL of the query/table that is the Record Source of the report?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    Shambler2 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Location
    Perris, CA
    Posts
    11
    SELECT OvenRoastTemps.Timestamp, Nz([Thermal_1],0) AS [Thermal 1], Nz([Thermal_2],0) AS [Thermal 2], Nz([Thermal_3],0) AS [Thermal 3], Nz([Thermal_4],0) AS [Thermal 4], Nz([Thermal_5],0) AS [Thermal 5], Nz([Thermal_6],0) AS [Thermal 6], Nz([Thermal_7],0) AS [Thermal 7], Nz([Thermal_8],0) AS [Thermal 8], Nz([Thermal_9],0) AS [Thermal 9], Nz([Thermal_10],0) AS [Thermal 10], IIf([Thermal 1]>=72 And [Thermal 2]>=72 And [Thermal 3]>=72 And [Thermal 4]>=72 And [Thermal 5]>=72 And [Thermal 6]>=69 And [Thermal 7]>=72 And [Thermal 8]>=72 And [Thermal 9]>=72 And [Thermal 10]>=72,"PASS","FAIL") AS [Pass/Fail]
    FROM OvenRoastTemps
    WHERE (((OvenRoastTemps.Timestamp) Between [Forms]![Oven Temp Data]![StartDate] And [Forms]![Oven Temp Data]![EndDate]));

    I need to figure out how to consecutivly count the [Pass/Fail] field to see if it stayed that way for one hour. (Or 5 records. Each record timestamp is 15 minutes)

  8. #8
    Shambler2 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2011
    Location
    Perris, CA
    Posts
    11
    I have lower values specifed in the sensors( [Thermal 9]>=72 ) just so I was able to test my data. Not many temperatures measured over 100 degrees. But eventually the goal will be 170.

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

Similar Threads

  1. Open report on value of textbox
    By blueraincoat in forum Reports
    Replies: 39
    Last Post: 09-21-2011, 01:53 AM
  2. Display PASS or FAIL using Unbound textbox
    By Shambler2 in forum Reports
    Replies: 7
    Last Post: 06-02-2011, 11:19 AM
  3. Replies: 0
    Last Post: 05-03-2011, 05:58 AM
  4. using unbound combo box to filter report
    By jlclark4 in forum Reports
    Replies: 1
    Last Post: 01-25-2011, 04:12 PM
  5. Using Dlookup in unbound text box in report
    By PrintShopSup in forum Reports
    Replies: 3
    Last Post: 12-27-2010, 10:29 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