Private Sub cmdSearch_Click()
DoCmd.OpenQuery(qryDataSheet,[View As AcView = acViewNormal], [DataMode As AcOpenDataMode = acReadOnly])
Dim strSQLHead As String
Dim strSQLWhere As String
Dim strSQLOrderBy As String
Dim strSQL As String
Dim strJoin As String
strJoin = " AND "
strSQLHead = "SELECT * FROM qryDataSheet "
If Len(Me.cboJobName & vbNullString) Then
If Len(strSQLWhere) = 0 Then
strSQLWhere = "WHERE "
End If
strSQLWhere = strSQLWhere & "[JobName] = " & Me.cboJobName
strSQLWhere = strSQLWhere & strJoin
End If
If Len(Me.cboBuildingType & vbNullString) Then
If Len(strSQLWhere) = 0 Then
strSQLWhere = "WHERE "
End If
strSQLWhere = strSQLWhere & "[BuildingType] = " & Me.cboBuildingType
strSQLWhere = strSQLWhere & strJoin
End If
If Len(Me.cboLaborDifficulty & vbNullString) Then
If Len(strSQLWhere) = 0 Then
strSQLWhere = "WHERE "
End If
strSQLWhere = strSQLWhere & "[LaborDifficulty] = " & Me.cboLaborDifficulty
strSQLWhere = strSQLWhere & strJoin
End If
If Len(Me.cboLaborRate & vbNullString) Then
If Len(strSQLWhere) = 0 Then
strSQLWhere = "WHERE "
End If
strSQLWhere = strSQLWhere & "[LaborRate] = " & Me.cboLaborRate
strSQLWhere = strSQLWhere & strJoin
End If
End Sub