Hi,
I am using the coding below to search a recordset, I have used exactly the same coding on another database and it works, but it will not work now.
anyone know why?
Thanks
Hope this is of use, Rob.![[yoda] [yoda] [yoda]](/data/assets/smilies/yoda.gif)
I am using the coding below to search a recordset, I have used exactly the same coding on another database and it works, but it will not work now.
Code:
Private Sub Command13_Click()
Dim strSql, strsql2 As String
Dim rs, rs2 As DAO.Recordset
Dim db As DAO.Database
If Trim$(Me!txtCriterion & "") = "" Then
MsgBox "enter a value first..."
Else
Set db = CurrentDb
strSql = ("select rstatus from tblLoggedCases " _
& "where UniqueID = '" & Me!txtCriterion & "'")
Set rs = db.OpenRecordset(strSql) '****ERROR IS HERE****
If Not rs.BOF And Not rs.EOF Then
' record is found
If Trim$(rs.Fields("rStatus").Value & "") <> "Closed" Then
' field is "blank
DoCmd.OpenForm "frmCloseACase", , , "UNiqueID = '" & Me!txtCriterion & "'"
Me.txtCriterion = ""
Else
'closead field has a value in.
strsql2 = ("select Owner from tblLoggedCases " & _
"where Uniqueid = '" & Me!txtCriterion & "'")
Set rs2 = db.OpenRecordset(strsql2)
strsql3 = ("select rStatus from tblLoggedCases " & _
"where UNiqueId = '" & Me!txtCriterion & "'")
Set rs3 = db.OpenRecordset(strsql3)
MsgBox "Record has already been closed by " & vbCrLf _
& "Username - " & rs2.Fields("Owner").Value & vbCrLf _
& "Date Closed - " & rs3.Fields("DateClosed").Value & vbCrLf _
, vbExclamation
Me.txtCriterion = ""
End If
Else
MsgBox "Record Doesn't exist..."
Me.txtCriterion = ""
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End If
End Sub
anyone know why?
Thanks
Hope this is of use, Rob.
![[yoda] [yoda] [yoda]](/data/assets/smilies/yoda.gif)