Error: Jet Cannot Find 'tblBehavioralRating'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lisa McDaniel
    New Member
    • Jan 2012
    • 1

    Error: Jet Cannot Find 'tblBehavioralRating'

    I get that error when trying to create an error message when entering duplicate employee name by attaching to a field with a list box to the before update event. Here is the code I am using and I have tried everything including renaming the table so there is not a space between Behavioral Rating. Can anyone help?
    Code:
    Private Sub Employee_Name_BeforeUpdate(Cancel As Integer)
     Dim Answer As Variant
    
     Answer = DLookup("[Employee_Name]", "tblBehavioralRating", "[Employee_Name] = '" & Me.Employee_Name & "'")
     If Not IsNull(Answer) Then
      MsgBox "Employee Record already exists" & vbCrLf & "Please use Find Record to Edit Button.", vbCritical + vbOKOnly + vbDefaultButton1, "Duplicate"
    
      Cancel = True
      Me.Employee_Name.Undo
     
     Else:
     End If
    End Sub
    Last edited by NeoPa; Jan 26 '12, 10:18 PM. Reason: Added mandatory [CODE] tags for you
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    What line is the error on and what is the error text?

    Comment

    • dsatino
      Contributor
      • May 2010
      • 393

      #3
      I think you should probably fix some other issues before trying to solve this. I have no idea what you're doing of course but, in general, using a name as unique identifier is not good practice since names are not unique. I'd guess there's probably an employee table and, hopefully, each employee has some sort of unique ID. You should use that instead. Which then brings us to the question of why you need a table for this. If an employee can have only one behavioral record, is there a reason for an additional table? Or maybe you just need to add a field(s) to your employee table.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32656

        #4
        Lisa, as Rabbit says this question (including title) makes no sense without the basic information. Surely no-one could possibly consider the error code alone adequate - without specifying even the line it occurred on or the text of the error message. Please remember in future as it will waste less of people's time and effort.

        I looked up the error message from the number and it pertains to the table name supplied not matching any table or query in your database. From that I infer that your DLookup() line (#4) has the problem and that the problem is that your table is not actually called [tblBehavioralRa ting] at all. If the actual table name has a space in it then you can refer to it in the code as follows :
        Code:
        Answer = DLookup("[Employee_Name]", _
                         "[tblBehavioral Rating]", _
                         "[Employee_Name] = '" & Me.Employee_Name & "'")
        PS. DSatino's point is also a good one and you should follow that up ;-)

        Comment

        Working...