P
Penny
Hi All,
In a search form I have code that builds a select statement using a query
taking values from form controls as parameters and then adding a few more
criteria generated by passing other values in controls through specialized
sub routines. The code then sets the record source of a sub form to the
select statement. Works a treat. This whole process can take up to 30
seconds over the network and I want to visually let the user know that the
search is executing. I dont display the status bar so text or a progress bar
is out of the question there. I've tried displaying an hourglass or custom
built form during the process(as implemented in the code below) but the
hourglass 'displays' only for a tiny fraction of a second at the end of the
process(no good to me) or the 'frmSearchIndicator' displays only its border
and none of the detail section.
Any ideas?
Regards,
Penny.
.....................................
Sub lblSearch_Click()
On Error GoTo HandleErrors
' Create a WHERE clause using search criteria entered by user and
' set RecordSource property of frmSearchCandidatesGenericSUBResults.
Dim strBaseSQL As String
Dim strCriteria As String
Dim strRecordSource As String
Dim intArgCount As Integer
Dim Tmp As Variant
DoCmd.Hourglass True
'DoCmd.openForm "frmSearchIndicator"
' Initialize argument count
intArgCount = 0
strBaseSQL = "SELECT * FROM qrySearchCandidates WHERE "
strCriteria = ""
' Use values entered in text boxes in form to create more criteria for
WHERE Clause.
AddToWhere1 [BasisOfEmployment], "[WorkingHoursSought]", strCriteria,
intArgCount
AddToWhere2 [TypingTestAccuracy], "[TypingTestAccuracy]", strCriteria,
intArgCount
AddToWhere4 [WillingToTemp], "[WillingToTemp]", strCriteria, intArgCount
AddToWhere8 [OverallGrade], "[OverallGrade]", strCriteria, intArgCount
' If no criteria specified, return all records.
If strCriteria = "" Then
strCriteria = "True"
End If
' Create SELECT statement.
strRecordSource = strBaseSQL & strCriteria
' Set RecordSource property of frmCandidateSearchSubResults.
Me![Child1].Form.RecordSource = strRecordSource
' If no records match criteria, display message.
' Move focus to Clear button.
If Me![Child1].Form.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no records that match the criteria you have
entered.", 48, "No Records Found"
'Me.lblClear_Click
Else
' Enable control in detail section.
Me![Child1].Enabled = True
End If
'DoCmd.Close acForm, "frmSearchIndicator"
DoCmd.Hourglass False
ExitHere:
Exit Sub
HandleErrors:
MsgBox Err.Number & ": " & Err.Description, , "lblSearch_Click"
Resume ExitHere
End Sub
......................................
In a search form I have code that builds a select statement using a query
taking values from form controls as parameters and then adding a few more
criteria generated by passing other values in controls through specialized
sub routines. The code then sets the record source of a sub form to the
select statement. Works a treat. This whole process can take up to 30
seconds over the network and I want to visually let the user know that the
search is executing. I dont display the status bar so text or a progress bar
is out of the question there. I've tried displaying an hourglass or custom
built form during the process(as implemented in the code below) but the
hourglass 'displays' only for a tiny fraction of a second at the end of the
process(no good to me) or the 'frmSearchIndicator' displays only its border
and none of the detail section.
Any ideas?
Regards,
Penny.
.....................................
Sub lblSearch_Click()
On Error GoTo HandleErrors
' Create a WHERE clause using search criteria entered by user and
' set RecordSource property of frmSearchCandidatesGenericSUBResults.
Dim strBaseSQL As String
Dim strCriteria As String
Dim strRecordSource As String
Dim intArgCount As Integer
Dim Tmp As Variant
DoCmd.Hourglass True
'DoCmd.openForm "frmSearchIndicator"
' Initialize argument count
intArgCount = 0
strBaseSQL = "SELECT * FROM qrySearchCandidates WHERE "
strCriteria = ""
' Use values entered in text boxes in form to create more criteria for
WHERE Clause.
AddToWhere1 [BasisOfEmployment], "[WorkingHoursSought]", strCriteria,
intArgCount
AddToWhere2 [TypingTestAccuracy], "[TypingTestAccuracy]", strCriteria,
intArgCount
AddToWhere4 [WillingToTemp], "[WillingToTemp]", strCriteria, intArgCount
AddToWhere8 [OverallGrade], "[OverallGrade]", strCriteria, intArgCount
' If no criteria specified, return all records.
If strCriteria = "" Then
strCriteria = "True"
End If
' Create SELECT statement.
strRecordSource = strBaseSQL & strCriteria
' Set RecordSource property of frmCandidateSearchSubResults.
Me![Child1].Form.RecordSource = strRecordSource
' If no records match criteria, display message.
' Move focus to Clear button.
If Me![Child1].Form.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no records that match the criteria you have
entered.", 48, "No Records Found"
'Me.lblClear_Click
Else
' Enable control in detail section.
Me![Child1].Enabled = True
End If
'DoCmd.Close acForm, "frmSearchIndicator"
DoCmd.Hourglass False
ExitHere:
Exit Sub
HandleErrors:
MsgBox Err.Number & ": " & Err.Description, , "lblSearch_Click"
Resume ExitHere
End Sub
......................................