Tronsliver
Technical User
Hoping someone can help with this: Listed below is code for one of my modules. When I try and delete a record this code is activated. Basically it's function is to go through a recordset and find occurences of a name and report back how many instances it found. However, when I run the program the heading of the module is highlighted in yellow (error) and the message "Can't find project or Library" message box pops up. Also the first instance of "&" is highlighted in blue within the module. Thanks:
Private Sub Form_Delete(Cancel As Integer)
Dim rst As Recordset
Dim x As Byte
Dim varx As Byte
Set rst = CurrentDb().OpenRecordset("Rater", dbOpenTable)
x = Findx(varx)
If x > 0 Then
MsgBox (Forms!RaterF!LName & " is in " & x & " rating scheme(s)." _
& Chr(13) & "Must replace " & Forms!RaterF!LName & " in all" & Chr(13) & _
"schemes before you can delete "
Forms!RaterF!SSN.SetFocus
End
End If
End Sub
Public Function Findx(varx As Byte) As Byte
Dim rst As Recordset
Dim OfficerName, Response As String
Set rst = CurrentDb().OpenRecordset("OfficerQ", dbOpenDynaset)
varx = 0
With rst
.MoveFirst
Do Until .EOF
If (Forms!RaterF!OfficerID = !RaterNum) Or (Forms!RaterF!OfficerID = !IntNum) Or _
(Forms!RaterF!OfficerID = !SeniorNum) Then
varx = varx + 1
End If
.MoveNext
Loop
Findx = varx
rst.Close
End With
End Function
Private Sub Form_Delete(Cancel As Integer)
Dim rst As Recordset
Dim x As Byte
Dim varx As Byte
Set rst = CurrentDb().OpenRecordset("Rater", dbOpenTable)
x = Findx(varx)
If x > 0 Then
MsgBox (Forms!RaterF!LName & " is in " & x & " rating scheme(s)." _
& Chr(13) & "Must replace " & Forms!RaterF!LName & " in all" & Chr(13) & _
"schemes before you can delete "
Forms!RaterF!SSN.SetFocus
End
End If
End Sub
Public Function Findx(varx As Byte) As Byte
Dim rst As Recordset
Dim OfficerName, Response As String
Set rst = CurrentDb().OpenRecordset("OfficerQ", dbOpenDynaset)
varx = 0
With rst
.MoveFirst
Do Until .EOF
If (Forms!RaterF!OfficerID = !RaterNum) Or (Forms!RaterF!OfficerID = !IntNum) Or _
(Forms!RaterF!OfficerID = !SeniorNum) Then
varx = varx + 1
End If
.MoveNext
Loop
Findx = varx
rst.Close
End With
End Function