The below code is searching for a record based on information entered on a form using a stored query. The results are in a recordset which is then sent back to a form.
I am having a problem with the code hanging when the recordset is passed back to the form (Put a *** at the begining of the line of code that hangs). Access does not throw an error it justs acts as though it is still processing or waiting for a db response and the only thing I can do is kill the program via Task Manager. It does not hang everytime but most of the time and I can not seem to find a pattern.
CODE
Public Sub SearchScorecard(frmScorecard As Form_Search_Scorecard_Form, frmSCDatasheet As SubForm)
Dim db As DAO.Database
Dim rstScoreCard As DAO.Recordset
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Set db = CurrentDb
If frmScorecard.txtScorecardID <> "" Then
Set qdf = db.QueryDefs("Q_SCORECARD_ByScorecardID")
qdf.Parameters("currScorecardID") = frmScorecard.txtScorecardID
Else
Set qdf = db.QueryDefs("Q_SCORECARD_SearchAll")
qdf.Parameters("currPeople") = frmScorecard.cboName
qdf.Parameters("currTeam") = frmScorecard.cboTeam
qdf.Parameters("currTicket") = frmScorecard.txtTicket
qdf.Parameters("currCategory") = frmScorecard.cboCategory
qdf.Parameters("currType") = frmScorecard.cboType
qdf.Parameters("currItem") = frmScorecard.cboItem
qdf.Parameters("currQueue") = frmScorecard.cboQueueType
qdf.Parameters("currServiceType") = frmScorecard.cboServiceType
qdf.Parameters("currEvalDate") = frmScorecard.txtEvalDate
qdf.Parameters("currCanceled") = frmScorecard.ChartSpace
End If
Set rstScoreCard = qdf.OpenRecordset(dbOpenDynaset)
If rstScoreCard.BOF And rstScoreCard.EOF Then
MsgBox ("No Record Found!")
Exit Sub
End If
***Set frmSCDatasheet.Form.Recordset = rstScoreCard 'Hangs here
End Sub
END CODE
I am having a problem with the code hanging when the recordset is passed back to the form (Put a *** at the begining of the line of code that hangs). Access does not throw an error it justs acts as though it is still processing or waiting for a db response and the only thing I can do is kill the program via Task Manager. It does not hang everytime but most of the time and I can not seem to find a pattern.
CODE
Public Sub SearchScorecard(frmScorecard As Form_Search_Scorecard_Form, frmSCDatasheet As SubForm)
Dim db As DAO.Database
Dim rstScoreCard As DAO.Recordset
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Set db = CurrentDb
If frmScorecard.txtScorecardID <> "" Then
Set qdf = db.QueryDefs("Q_SCORECARD_ByScorecardID")
qdf.Parameters("currScorecardID") = frmScorecard.txtScorecardID
Else
Set qdf = db.QueryDefs("Q_SCORECARD_SearchAll")
qdf.Parameters("currPeople") = frmScorecard.cboName
qdf.Parameters("currTeam") = frmScorecard.cboTeam
qdf.Parameters("currTicket") = frmScorecard.txtTicket
qdf.Parameters("currCategory") = frmScorecard.cboCategory
qdf.Parameters("currType") = frmScorecard.cboType
qdf.Parameters("currItem") = frmScorecard.cboItem
qdf.Parameters("currQueue") = frmScorecard.cboQueueType
qdf.Parameters("currServiceType") = frmScorecard.cboServiceType
qdf.Parameters("currEvalDate") = frmScorecard.txtEvalDate
qdf.Parameters("currCanceled") = frmScorecard.ChartSpace
End If
Set rstScoreCard = qdf.OpenRecordset(dbOpenDynaset)
If rstScoreCard.BOF And rstScoreCard.EOF Then
MsgBox ("No Record Found!")
Exit Sub
End If
***Set frmSCDatasheet.Form.Recordset = rstScoreCard 'Hangs here
End Sub
END CODE