Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Sep 2002
    Location
    Brookings, South Dakota, USA
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Run-Time Error 3134 (2003/sp1)

    I'm getting the error when this code runs in a bound combo box on a form:

    Private Sub cboLevel_NotInList(NewData As String, Response As Integer)
    If MsgBox("The Specialization you entered " & NewData & " does not occur in the list." & vbCrLf & _
    "Do you want to add it?", vbYesNo + vbQuestion) = vbYes Then
    Dim strSQL As String
    strSQL = "INSERT INTO tblProgramLevel (Level) VALUES (" & _
    Chr$(34) & NewData & Chr$(34) & ")"
    CurrentDb.Execute strSQL
    Response = acDataErrAdded
    Else
    cboLevel.Undo
    Response = acDataErrContinue
    End If
    End Sub

    I've also tried this:
    Private Sub cboLevel_NotInList(NewData As String, Response As Integer)
    If MsgBox("The Specialization you entered " & NewData & " does not occur in the list." & vbCrLf & _
    "Do you want to add it?", vbYesNo + vbQuestion) = vbYes Then
    Dim strSQL As String
    strSQL = "INSERT INTO tblProgramLevel (Level) VALUES (" & _
    Chr$(34) & NewData & Chr$(34) & ")"
    CurrentDb.Execute strSQL, dbFailOnError
    Response = acDataErrAdded
    Else
    cboLevel.Undo
    Response = acDataErrContinue
    End If
    End Sub

    The table, field names, and data type are all correct as far as I can see. I can change the table and field names and insert the new data into another table just fine, can you see what the problem is? Thanks, Tammy

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Run-Time Error 3134 (2003/sp1)

    Try this:

    strSQL = "INSERT INTO tblProgramLevel (Level) SELECT (" & _
    Chr$(34) & NewData & Chr$(34) & ") As Expr1"
    Charlotte

  3. #3
    Lounger
    Join Date
    Sep 2002
    Location
    Brookings, South Dakota, USA
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run-Time Error 3134 (2003/sp1)

    Thanks for the quick response Charlotte, but no luck. This is the line that's highlighted
    CurrentDb.Execute strSQL, dbFailOnError
    Does that make any difference? Tammy

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Run-Time Error 3134 (2003/sp1)

    "Level" is a reserved word in SQL, so if you want to use it as a field name, you must put it between square brackets:

    strSQL = "INSERT INTO tblProgramLevel ( [Level] ) VALUES (" & _
    Chr$(34) & NewData & Chr$(34) & ")"

  5. #5
    Lounger
    Join Date
    Sep 2002
    Location
    Brookings, South Dakota, USA
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run-Time Error 3134 (2003/sp1)

    That was it! Thanks for your help. Tammy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •