i get the above runtime error on the following line of code
when i try to update a reord in my form
when it gets to the line
Set rs = DBEngine(0)(0).OpenRecordset(strSql)
the entire code is posted below
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim rs As DAO.Recordset
Dim strCode2Use As String
Dim strSql As String
Dim i As Integer
If Len(Forename) >= 2 Then
If Len(Surname) >= 2 Then
strCode2Use = Left$(Surname, 2) & Left$(Forename, 2)
strSql = "SELECT TOP 1 LionCode FROM lions WHERE LionCode
Like """ & _
strCode2Use & "*"" ORDER BY Code DESC;"
Set rs = DBEngine(0)(0).OpenRecordset(strSql)
If rs.RecordCount > 0 Then 'If we found a match
i = CInt(Right(rs!lionCode, 2)) + 1 'Increment the num in
last 2characters.
End If
rs.Close
lionCode = strCode2Use & Format(i, "00")
Else
Cancel = True
MsgBox "FirstName must be at least 2 characters."
End If
End If
Set rs = Nothing
End Sub