Results 1 to 12 of 12
  1. #1
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68

    My add button stopped working. I'm trying to trouble shoot what could have happend. Pasted code

    Private Sub CmdAdd_Click()
    If IsNull(Me.ComboFiscal) Then ' No business unit


    MsgBox ("Please add Fiscal Year!"), vbOKCancel ' Tell user
    Me.ComboFiscal.SetFocus ' Focus the control
    Exit Sub ' Exit the method
    End If ' End the IsNull test
    If IsNull(Me.txtContact) Then ' No business unit
    MsgBox ("Please add Contact!"), vbOKCancel ' Tell user
    Me.txtContact.SetFocus ' Focus the control
    Exit Sub ' Exit the method
    End If ' End the IsNull test

    If IsNull(Me.ComboMonth) Then ' No business unit
    MsgBox ("Please add Month!"), vbOKCancel ' Tell user
    Me.ComboMonth.SetFocus ' Focus the control
    Exit Sub ' Exit the method
    End If ' End the IsNull test

    If Nz(Me.TxtActualBenchmark, "") = "" And Me.Comboyesorno.Visible = False Then ' No business unit
    MsgBox ("Please add Results!"), vbOKCancel ' Tell user
    Me.txtContact.SetFocus ' Focus the control
    Exit Sub ' Exit the method
    End If ' End the IsNull test

    If (Me.ComboGoals.Value = "") Then ' No business unit
    MsgBox ("Please add Goals!"), vbOKCancel ' Tell user
    Me.ComboGoals.SetFocus ' Focus the control
    Exit Sub ' Exit the method
    End If ' End the IsNull test
    If Nz(Me.Comboyesorno, "") = "" And Me.Comboyesorno.Visible = True Then ' No business unit
    MsgBox ("Please add Yes or No!"), vbOKCancel ' Tell user
    Me.txtContact.SetFocus ' Focus the control
    Exit Sub ' Exit the method
    End If ' End the IsNull test


    Select Case TxtActualBenchmark
    Case "N/A"

    Case "At least one program every 6 months"
    Select Case Me.ComboMonth
    Case "January", "February", "March", "April", "May", "July", "August", "September", "October", "November"
    MsgBox "Please put N/A", vbOKCancel
    Case "June", "December"
    'do nothing
    End Select

    Case Else 'or NOT "N/A"
    'SOMETHIN
    End Select
    Select Case TxtActualBenchmark
    Case "N/A"

    Case "25% Implemented every 4 months"
    Select Case Me.ComboMonth
    Case "January", "February", "March", "May", "July", "September", "October", "November"
    MsgBox "Please put N/A", vbOKCancel
    Case "April", "August", "December"
    'do nothing
    End Select

    Case Else 'or NOT "N/A"
    'SOMETHIN
    End Select





    If IsNumeric(Me.TxtActualBenchmark) = "False" Then
    Select Case Me.ComboGoals.Column(2)
    Case 1, 4, 6, 10, 11, 12, 13, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 46, 47, 48, 50, 51, 56, 59, 61, 74, 75, 79, 80, 84, 85, 86, 87, 88, 89, 90, 91, 96, 99, 100, 108, 110, 112, 115, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 141, 142, 143, 144, 145, 146, 147, 148, 149, 152, 153, 154, 156, 158, 159, 160, 161, 162, 163, 164, 165, 166, 171, 172, 173, 174, 184, 185, 186, 187, 188, 190, 191, 192, 193, 195, 196, 197, 200, 204, 205, 208, 209, 210, 211, 213, 214, 216, 219
    Me.TxtActualBenchmark.Undo
    MsgBox "Please enter a numeric value ", _
    vbInformation, "Missing Information"
    End Select
    Exit Sub
    End If
    If InStr(Me.TxtActualBenchmark, ".") = 0 Then
    Select Case Me.ComboGoals.Column(2)
    Case 2, 3, 9, 20, 43, 45, 54, 55, 58, 60, 97, 103, 116, 117, 150, 167, 168, 169, 182, 194, 199, 201, 207
    MsgBox "Please enter a decimal", vbInformation, "Missing Information"
    Cancel = True
    End Select
    Exit Sub
    End If


    'Add data to form
    CurrentDb.Execute "INSERT INTO Scorecards (ForTheMonth,FiscalYear,Groups,Contact,Goals,Bench marks,Results,Comments,MetGoal)" & _
    "VALUES('" & Me.ComboMonth & "','" & Me.ComboFiscal & "','" & Me.ComboDepartment & "','" & Me.txtContact & "','" & Me.ComboGoals & "','" & Me.txtBenchmarks & "','" & Me.TxtActualBenchmark & "','" & Me.txtComments & "','" & Me.txtMetGoal & "');"
    'message box

    'Requery Form
    frmscorecardssub.Form.Requery
    'Clear Form
    CmdClear_Click
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Does it give an error? If so , where?
    Does it NOT do something at a certain point?

    lil help.

    1st
    If IsNumeric(Me.TxtActualBenchmark) = "False" Then
    FALSE is a numerica value .... NO QUOTES.

    IF not IsNumeric(Me.TxtActualBenchmark)
    or
    if IsNumeric(Me.TxtActualBenchmark) = false

  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,870
    It would be helpful to readers if you:
    a)provided some context as to the purpose of the database
    b)showed some of your debugging steps with some results/error messages...
    c) asked specific question

    I recommend you research the Access Smart Indenter ( a free utility to indent code) and
    MZTools for VBA (another great free utility) and
    use Code tags when publishing/posting code.

    For debugging guidelines/technques see http://www.cpearson.com/excel/DebuggingVBA.aspx

  4. #4
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    Thank I will take the quotes off of False. When I get home after work I will upload the database. I can't do it from work.

  5. #5
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    I don't get any error messages. Nothing happens when I hit add, instead of the new record going into to the table/subform

  6. #6
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    I think I narrowed it down to this code below, maybe those are "too many" maybe it is slowing it down. I could be wrong.


    My "Please add results!" pop up works


    When I try to add a result that is a "decimal" answer not numeric it works my "numeric" and yes or no questions are the ones giving me trouble or that appears to be the case, going to keep working on it, I will post it tonight, if I can't figure it out

    I have an earlier copy of it with almost the same code, just not as many goal numbers entered, that is working









    If IsNumeric(Me.TxtActualBenchmark) = "False" Then
    Select Case Me.ComboGoals.Column(2)
    Case 1, 4, 6, 10, 11, 12, 13, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 46, 47, 48, 50, 51, 56, 59, 61, 74, 75, 79, 80, 84, 85, 86, 87, 88, 89, 90, 91, 96, 99, 100, 108, 110, 112, 115, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 141, 142, 143, 144, 145, 146, 147, 148, 149, 152, 153, 154, 156, 158, 159, 160, 161, 162, 163, 164, 165, 166, 171, 172, 173, 174, 184, 185, 186, 187, 188, 190, 191, 192, 193, 195, 196, 197, 200, 204, 205, 208, 209, 210, 211, 213, 214, 216, 219
    Me.TxtActualBenchmark.Undo
    MsgBox "Please enter a numeric value ", _
    vbInformation, "Missing Information"
    End Select
    Exit Sub
    End If

  7. #7
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Another thing you should always do is use the dbfailonerror option in the Currentdb.Execute:

    Currentdb.Execute "....", dbFailonerror

    This causes Access to generate a runtime error if there is a problem with the SQL; sometimes Access won't tell you the command failed - it just doesn't do anything.

  8. #8
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    Ok I have the error now. I think I know what happened. Some of the employees entered data today. So I appended their records into my Scorecards table. Maybe when I did that it messed something up but should not have. The error I am getting is Run Time error '3078' The microsoft access databse engine cannot find the input table or query. Make sure it exists and the name is spelled correctly.


    Sooooo I'm goning to do an easy fix and copy and paste my code into a saved older copy that doesn't have the appended records. That's the only thing I can think do. When I appended it didn't change the name so I am not sure why it would give me the error, anyway.

  9. #9
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    Nevermind that was not the error, I got that error by adding this just now
    DoCmd.SetWarnings True
    CurrentDb.Execute strSQL, dbFailOnError

  10. #10
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    This was messing it up. I think it works now but I only did one test


    If InStr(Me.TxtActualBenchmark, ".") = 0 Then
    Select Case Me.ComboGoals.Column(2)
    Case 2, 3, 9, 20, 43, 45, 54, 55, 58, 60, 97, 103, 116, 117, 150, 167, 168, 169, 182, 194, 199, 201, 207
    MsgBox "Please enter a decimal", vbInformation, "Missing Information"
    Cancel = True
    End Select
    Exit Sub
    End If

  11. #11
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    I really don't where to put dbFailonerror? before? after? I'm kinda new at this

    'Add data to form
    CurrentDb.Execute "INSERT INTO Scorecards (ForTheMonth,FiscalYear,Groups,Contact,Goals,Bench marks,Results,Comments,MetGoal)" & _
    "VALUES('" & Me.ComboMonth & "','" & Me.ComboFiscal & "','" & Me.ComboDepartment & "','" & Me.txtContact & "','" & Me.ComboGoals & "','" & Me.txtBenchmarks & "','" & Me.TxtActualBenchmark & "','" & Me.txtComments & "','" & Me.txtMetGoal & "');"

  12. #12
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You put it right after the SQL statement:

    CurrentDb.Execute "INSERT INTO Scorecards (ForTheMonth,FiscalYear,Groups,Contact,Goals,Bench marks,Results,Comments,MetGoal)" & _
    "VALUES('" & Me.ComboMonth & "','" & Me.ComboFiscal & "','" & Me.ComboDepartment & "','" & Me.txtContact & "','" & Me.ComboGoals & "','" & Me.txtBenchmarks & "','" & Me.TxtActualBenchmark & "','" & Me.txtComments & "','" & Me.txtMetGoal & "');", dbfailonerror

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

Similar Threads

  1. code for clear button is not working
    By tommyried in forum Programming
    Replies: 3
    Last Post: 03-13-2014, 02:50 AM
  2. URGENT - Code stopped working
    By RachelBedi in forum Forms
    Replies: 2
    Last Post: 10-26-2012, 10:31 PM
  3. Query not working with Directly pasted Tables
    By GAccess in forum Queries
    Replies: 3
    Last Post: 06-25-2012, 09:29 AM
  4. Access has stopped working
    By mrkaye in forum Access
    Replies: 0
    Last Post: 05-22-2012, 04:09 PM
  5. Access has stopped working
    By phillb in forum Forms
    Replies: 9
    Last Post: 01-10-2012, 12:22 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