Results 1 to 11 of 11
  1. #1
    athyeh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    170

    Need Troubleshooting

    Hi Folks,

    I have a form with the following VBA behind it.



    The first thing I need troubleshooting with is the "Process" and Combo68 field. Right now I have Operators selecting the process they are working and either "Full Shift", "Lunch", or "Break" in Combo68. Based on their selection in Combo 68 I have the goal adjusting down to either 75% (Break) or 50% (Lunch).

    I have the goal being recorded with each record so that I can query: Group By Hour and see what they their goal was for that hour. Therefore, if I select "Lunch" I need the Goal to be 13 until their hour runs out (handled by the Hour(Now()) statement).

    Also need the goal to 'reset' after every hour to "Full Shift' (Default Value for Combo68) and the Goal displayed in "Goal" to be 35. (which it is not currently doing)


    Code:
    Private Sub Process_Change()
        If Me![Process] = "Authenticate" Then Me![HardGoal] = 35
        If Me![Process] = "Receive" Then Me![HardGoal] = 35
    End Sub
    Private Sub LID_AfterUpdate()
    On Error GoTo ErrorHandler
        Const cQuote = """"
            Me!Operator.DefaultValue = cQuote & Me!Operator.Value & cQuote
            Me!Process.DefaultValue = cQuote & Me!Process.Value & cQuote
            Me!Goal.DefaultValue = cQuote & Me!Goal.Value & cQuote
        If Hour(Now()) > Nz(Me.tbxHour, -1) Then
            Me.Goal = 0
            Me.tbxCount = 0
            Me.tbxHour = Hour(Now())
        End If
        Me.tbxCount = Me.tbxCount + 1
        If Me![Combo68] = "Break" Then Me![Goal] = ([HardGoal] * 0.75)
        If Me![Combo68] = "Full Shift" Then Me![Goal] = ([HardGoal])
        If Me![Combo68] = "Lunch" Then Me![Goal] = ([HardGoal] * 0.5)
    DoCmd.RunCommand acCmdSaveRecord
    Me.Requery
    ExitHandler:
        Exit Sub
    ErrorHandler:
        Select Case Err
            Case 3022
                MsgBox "LID has already been recorded. Please use alternative LID."
                DoCmd.Hourglass False
                Resume ExitHandler
            Case Else
                MsgBox Err.Description
                DoCmd.Hourglass False
                Resume ExitHandler
            End Select
        Exit Sub
    End Sub

  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,930
    If 'it is not currently doing' then what is it doing - error message, wrong results, nothing? Have you step debugged? See link at bottom of my post.
    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
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    What testing scheme did you do/have before allowing "Operators" to use the database?
    Did the issue happen during testing? Did you actually test this part?

  4. #4
    athyeh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    170
    Hi Folks,

    Thank you for your replies.

    When I say it is not "Working" I mean that at the end of the hour, Process type switches back to "Full Shift" but "Goal" stays at 26 or 13.

    As far as testing goes, I currently have 36 people testing it everyday and this is one of two main 'bugs' that needs to be troubleshooted.

  5. #5
    athyeh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    170
    I'm wondering now if this problem might be better solved through a query?

    Set every record's goal = 35 (no more shift type selection)

    Then through the query just do:

    SELECT Sum(Table1.Goal)-60 AS SumOfGoal
    FROM Table1;

    To get the adjusted goal.

    The question then becomes, how to adjust the query to account for people working longer/shorter than their standard 8 hours?

  6. #6
    athyeh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    170
    I have identified the problem. With the code below, Goal updates back to 35, at the end of every hour just fine, until I change the Control Source of Me.Goal to Goal (a field in my table) (I need to record the associated goal rang-in with each record). Why would this be and how can I troubleshoot this?

    Code:
    Option Compare Database
    Private Sub Form_Timer()
        Me!Clock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm:ss AMPM")
    End Sub
    Private Sub Option102_Click()
        Me.LID = CEMA
    End Sub
    Private Sub Process_Change()
        If Me![Process] = "Authenticate" Then Me![HardGoal] = 35
        If Me![Process] = "Receive" Then Me![HardGoal] = 35
    End Sub
    Private Sub Combo68_Change()
        If Me![Combo68] = "Break" Then Me![Goal] = ([HardGoal] * 0.75)
        If Me![Combo68] = "Full Shift" Then Me![Goal] = ([HardGoal])
        If Me![Combo68] = "Lunch" Then Me![Goal] = ([HardGoal] * 0.5)
    End Sub
    Private Sub LID_AfterUpdate()
    On Error GoTo ErrorHandler
        Const cQuote = """"
            Me!Operator.DefaultValue = cQuote & Me!Operator.Value & cQuote
            Me!Process.DefaultValue = cQuote & Me!Process.Value & cQuote
            Me!Goal.DefaultValue = cQuote & Me!Goal.Value & cQuote
        If Hour(Now()) > Nz(Me.tbxHour, -1) Then
            Me.Combo68 = "Full Shift"
            Me.Goal = 35
            Me.tbxCount = 0
            Me.tbxHour = Hour(Now())
        End If
        Me.tbxCount = Me.tbxCount + 1
    DoCmd.RunCommand acCmdSaveRecord
    Me.Requery
    ExitHandler:
        Exit Sub
    ErrorHandler:
        Select Case Err
            Case 3022
                MsgBox "LID has already been recorded. Please use alternative LID."
                DoCmd.Hourglass False
                Resume ExitHandler
            Case Else
                MsgBox Err.Description
                DoCmd.Hourglass False
                Resume ExitHandler
            End Select
        Exit Sub
    End Sub
    Last edited by athyeh; 09-24-2013 at 10:38 AM.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    What do you mean by 'change the Control Source'? I don't see any ControlSource being changed. I do see Values and DefaultValue being changed.

    What is LID?

    You can troubleshoot by step debug. Follow the code as it executes. When results deviate from expected, correct the code.
    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.

  8. #8
    athyeh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    170
    Change The Control Source: In Design View, Click on Goal Textbox and then Go to "Data" tab, In Control Source field select "Goal" (Field in my Table), LID is an abbreviation of the name we associate with the barcode.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    You set the ControlSource property then use code to set its Value. Are you just continually changing the Value of the same record over and over? I don't know how user interacts with form. When do they move to new record? How does this impact the count value saved to Goal? Again, you will have to step debug. Do exactly what the user does, only one little step at a time and examine the code at each step of the process. Do events trigger? Are variables set as expected? Does code branch when it should?
    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.

  10. #10
    athyeh is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    170
    Yesterday: 9 Hours of frustrating trial and error, 1 broken copy of the DB later, IT WORKS!

    Thank you for your replies. Thread Solved.

    Code:
    Option Compare Database
    Private Sub Form_Timer()
        Me!Clock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm:ss AMPM")
    End Sub
    Private Sub Process_Change()
        If Me![Process] = "Authenticate" Then Me![HardGoal] = 35
        If Me![Process] = "Receive" Then Me![HardGoal] = 35
    End Sub
    Private Sub Combo68_Change()
        If Me![Combo68] = "Break" Then Me![Goal] = ([HardGoal] * 0.75)
        If Me![Combo68] = "Full Shift" Then Me![Goal] = ([HardGoal])
        If Me![Combo68] = "Lunch" Then Me![Goal] = ([HardGoal] * 0.5)
    End Sub
    Private Sub LID_AfterUpdate()
    On Error GoTo ErrorHandler
        Const cQuote = """"
            Me!Operator.DefaultValue = cQuote & Me!Operator.Value & cQuote
            Me!Process.DefaultValue = cQuote & Me!Process.Value & cQuote
            Me!Combo68.DefaultValue = cQuote & Me!Combo68.Value & cQuote
        If Hour(Now()) > Nz(Me.tbxHour, -1) Then
            Me.tbxCount = 0
            Me.Goal = 35
            Me.Combo68 = "Full Shift"
            Me.tbxHour = Hour(Now())
            Me!Combo68.DefaultValue = cQuote & Me!Combo68.Value & cQuote
        End If
        Me.tbxCount = Me.tbxCount + 1
    DoCmd.RunCommand acCmdSaveRecord
    Me.Requery
    ExitHandler:
        Exit Sub
    ErrorHandler:
        Select Case Err
            Case 3022
                MsgBox "LID has already been recorded. Please use alternative LID."
                DoCmd.Hourglass False
                Resume ExitHandler
            Case Else
                MsgBox Err.Description
                DoCmd.Hourglass False
                Resume ExitHandler
            End Select
        Exit Sub
    End Sub

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Sometimes that's what it takes. Congratulations!
    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.

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

Similar Threads

  1. Tab Control Troubleshooting
    By MayaMia in forum Forms
    Replies: 10
    Last Post: 10-09-2012, 12:32 PM
  2. Replies: 1
    Last Post: 01-05-2012, 10:06 AM
  3. Replies: 6
    Last Post: 07-21-2010, 11:47 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