Private Sub cboEvalDate_AfterUpdate() ' Lookup by date
Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Dim rsFind As DAO.Recordset
Set db = CurrentDb()
Set qd = db.QueryDefs!qryEvaluation
qd.Parameters!ClientFileNo = txtClientFileNo
qd.Parameters!WorkstationID = txtWorkstationID
qd.Parameters!EvalDate = cboEvalDate.Text
Set rs = qd.OpenRecordset
Set rsFind = Me.RecordsetClone
>>>>> SLOW HERE IF NO MATCH
rsFind.FindFirst "EvalDate = #" & Me.cboEvalDate & "# And ClientFileNo = " & Me.txtClientFileNo & " And WorkstationID = " & Me.txtWorkstationID
If rsFind.NoMatch Then 'if can't find date entered, ask if they want to add new one
Dim Msg, Style, Title, Response, MyString
Msg = cboEvalDate.Value & " " & "does not exist for this client. Would you like to add it?"
Style = vbYesNo + vbDefaultButton1 'Define buttons.
Title = "SOGoodwill" 'Define title.
Response = MsgBox(Msg, Style, Title) 'Display 'Last Updated on' message
If Response = vbYes Then 'If User chose Yes.
bNewRevu = True
Call AddEvalRcd
bNewRevu = False
cboName.Value = Null
cboWorkstation.Value = Null
cboEvalDate.Value = Null
DoCmd.GoToControl "fsubEvalService"
Else
DoCmd.GoToControl "cboName"
DoCmd.GoToControl "cboEvalDate"
cboEvalDate.Value = Null
End If
Else
Me.Bookmark = rsFind.Bookmark
Set rsFind = Nothing
Me.Refresh 'so newly added dates show in dropdown
cboName = Null
cboEvalDate.Value = Null
dblClientFileNo = 0
dblEvalID = 0
End If
End Sub
|