T
TKM
I took over this database and it is a mess. r seprate tabs to main form with
two additonal suforms to boot. Anyway I want to leave everything the way it
is but..A new department wants me to set up a filter so he can only see what
his department wants to see. Here is the code. How or where whould I begin
without hurting any portion of the so-called structure of this databases. I
only want to have him select the department from a button or cob once he
selects the loan he wants to see then filter out certain conditions. Please
help and it is most appreciated.
Sub UpdateConditionalCheckListItems2(LoanID As Integer)
On Error GoTo Err_Handler
Dim cn As New ADODB.Connection
Dim rstLoanChecklist As New ADODB.Recordset
Dim rstChecklist As New ADODB.Recordset
Dim rst As New ADODB.Recordset
Dim strSQL_Checklist As String
Dim strSQL_LOan As String
Dim rstLoan As New ADODB.Recordset
Set cn = CurrentProject.Connection
strSQL_LOan = "SELECT * from qsubCheckList_Loans WHERE LoanID = " &
LoanID
rstLoan.Open strSQL_LOan, cn, adOpenDynamic, adLockOptimistic
rstLoanChecklist.Open "pplCheckListLoanItems", cn, adOpenDynamic,
adLockOptimistic
'Add Main CheckList Items
strSQL_Checklist = "Select * from pplCheckListItems where
((CheckListActive=True) and (ParentCheckListID Is Null) and
(LoanCriteria<>Null))"
rstChecklist.Open strSQL_Checklist, cn, adOpenDynamic,
adLockOptimistic
While Not rstChecklist.EOF
rst.Open strSQL_LOan & " and " &
rstChecklist("LoanCriteria").Value, cn, adOpenDynamic, adLockOptimistic
If rst.EOF Then
rst.Close
GoTo next_item
End If
rst.Close
rst.Open "Select * from pplCheckListLoanItems where
loanid=" & LoanID & " and masterchecklistid=" &
rstChecklist("MasterChecklistID").Value, cn, adOpenDynamic, adLockOptimistic
If rst.EOF Then
rstLoanChecklist.AddNew
rstLoanChecklist("MasterCheckListID").Value =
rstChecklist("MasterCheckListID").Value
rstLoanChecklist("LoanID").Value = LoanID
rstLoanChecklist("GroupName").Value =
rstChecklist("GroupName").Value
rstLoanChecklist("ConditionCode").Value =
rstChecklist("ConditionCode").Value
rstLoanChecklist("CheckListHeading").Value =
rstChecklist("CheckListHeading").Value
rstLoanChecklist("CheckListDescription").Value =
rstChecklist("CheckListDescription").Value
rstLoanChecklist("ResponsibleParty").Value =
rstChecklist("DefaultResponsibleParty").Value
rstLoanChecklist("AMCCParty").Value =
rstChecklist("DefaultAMCCParty").Value
If rstLoan("LoanAssumedClosingDate").Value <> ""
And rstChecklist("DefaultDueDateOffsetFromCloseDate").Value <> "" Then
rstLoanChecklist("DueDate").Value =
DateAdd("D", -(rstChecklist("DefaultDueDateOffsetFromCloseDate").Value),
rstLoan("LoanAssumedClosingDate").Value)
End If
If rstChecklist("DefaultApplicable").Value =
False Then
rstLoanChecklist("ExemptionDate").Value = Date
rstLoanChecklist("ExemptionBy").Value =
"Default"
End If
rstLoanChecklist.Update
End If
rst.Close
next_item:
rstChecklist.MoveNext
Wend
Exit_Sub:
On Error Resume Next
rstChecklist.Close
rstLoan.Close
Set rstLoan = Nothing
two additonal suforms to boot. Anyway I want to leave everything the way it
is but..A new department wants me to set up a filter so he can only see what
his department wants to see. Here is the code. How or where whould I begin
without hurting any portion of the so-called structure of this databases. I
only want to have him select the department from a button or cob once he
selects the loan he wants to see then filter out certain conditions. Please
help and it is most appreciated.
Sub UpdateConditionalCheckListItems2(LoanID As Integer)
On Error GoTo Err_Handler
Dim cn As New ADODB.Connection
Dim rstLoanChecklist As New ADODB.Recordset
Dim rstChecklist As New ADODB.Recordset
Dim rst As New ADODB.Recordset
Dim strSQL_Checklist As String
Dim strSQL_LOan As String
Dim rstLoan As New ADODB.Recordset
Set cn = CurrentProject.Connection
strSQL_LOan = "SELECT * from qsubCheckList_Loans WHERE LoanID = " &
LoanID
rstLoan.Open strSQL_LOan, cn, adOpenDynamic, adLockOptimistic
rstLoanChecklist.Open "pplCheckListLoanItems", cn, adOpenDynamic,
adLockOptimistic
'Add Main CheckList Items
strSQL_Checklist = "Select * from pplCheckListItems where
((CheckListActive=True) and (ParentCheckListID Is Null) and
(LoanCriteria<>Null))"
rstChecklist.Open strSQL_Checklist, cn, adOpenDynamic,
adLockOptimistic
While Not rstChecklist.EOF
rst.Open strSQL_LOan & " and " &
rstChecklist("LoanCriteria").Value, cn, adOpenDynamic, adLockOptimistic
If rst.EOF Then
rst.Close
GoTo next_item
End If
rst.Close
rst.Open "Select * from pplCheckListLoanItems where
loanid=" & LoanID & " and masterchecklistid=" &
rstChecklist("MasterChecklistID").Value, cn, adOpenDynamic, adLockOptimistic
If rst.EOF Then
rstLoanChecklist.AddNew
rstLoanChecklist("MasterCheckListID").Value =
rstChecklist("MasterCheckListID").Value
rstLoanChecklist("LoanID").Value = LoanID
rstLoanChecklist("GroupName").Value =
rstChecklist("GroupName").Value
rstLoanChecklist("ConditionCode").Value =
rstChecklist("ConditionCode").Value
rstLoanChecklist("CheckListHeading").Value =
rstChecklist("CheckListHeading").Value
rstLoanChecklist("CheckListDescription").Value =
rstChecklist("CheckListDescription").Value
rstLoanChecklist("ResponsibleParty").Value =
rstChecklist("DefaultResponsibleParty").Value
rstLoanChecklist("AMCCParty").Value =
rstChecklist("DefaultAMCCParty").Value
If rstLoan("LoanAssumedClosingDate").Value <> ""
And rstChecklist("DefaultDueDateOffsetFromCloseDate").Value <> "" Then
rstLoanChecklist("DueDate").Value =
DateAdd("D", -(rstChecklist("DefaultDueDateOffsetFromCloseDate").Value),
rstLoan("LoanAssumedClosingDate").Value)
End If
If rstChecklist("DefaultApplicable").Value =
False Then
rstLoanChecklist("ExemptionDate").Value = Date
rstLoanChecklist("ExemptionBy").Value =
"Default"
End If
rstLoanChecklist.Update
End If
rst.Close
next_item:
rstChecklist.MoveNext
Wend
Exit_Sub:
On Error Resume Next
rstChecklist.Close
rstLoan.Close
Set rstLoan = Nothing