Solved

Run-time error '91': Object variable or With block variable not set

Posted on 2003-11-11
14
12,631 Views
Last Modified: 2013-11-26
I get a Run-time error '91': Object variable or With block variable not set on some machines and it runs fine on others.  Below is my code:

Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Author:
'Life Complaints System
'November 7, 2003
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Sets the Complaint Description Codes.
Private Sub cboComplaintDescription_Validate(Cancel As Boolean)
If Me.cboComplaintDescription = "Life-Agent Conduct" Then Me.cboComplaintDescriptionCodes = "CD10"
If Me.cboComplaintDescription = "Life-Death Claim" Then Me.cboComplaintDescriptionCodes = "CD11"
If Me.cboComplaintDescription = "Life-General Customer Service" Then Me.cboComplaintDescriptionCodes = "CD12"
If Me.cboComplaintDescription = "Life-Not Taken" Then Me.cboComplaintDescriptionCodes = "CD13"
If Me.cboComplaintDescription = "Life-Policy Performance" Then Me.cboComplaintDescriptionCodes = "CD14"
If Me.cboComplaintDescription = "Life-Surrender" Then Me.cboComplaintDescriptionCodes = "CD15"
End Sub
'Sets the distribution codes.
Private Sub cboDistributionChannel_Validate(Cancel As Boolean)
If Me.cboDistributionChannel = "Life-Citibank" Then Me.cboDistributionCodes = "DC10"
If Me.cboDistributionChannel = "Life-Citistreet/Direct Markets" Then Me.cboDistributionCodes = "DC11"
If Me.cboDistributionChannel = "Life-Smith Barney" Then Me.cboDistributionCodes = "DC12"
If Me.cboDistributionChannel = "Life-Prudential" Then Me.cboDistributionCodes = "DC13"
If Me.cboDistributionChannel = "Life-Independent Agents" Then Me.cboDistributionCodes = "DC14"
End Sub
'User wanted to be able to change date so automatic date function is disabled.
'Calculates the days to resolution.
Private Sub chkClosed_Click()
'Me.txtDateClosed = Date
Me.cboStatus = "Closed"
If Me.cboStatus = "Closed" Then
   If IsDate(Me.txtDateClosed.Text) And IsDate(Me.txtDateReceived.Text) Then
     Me.txtDaysToResolution.Text = Format(DateDiff("d", CDate(Me.txtDateClosed.Text), CDate(Me.txtDateReceived.Text)), "##0") * -1
  Else
     Me.txtDaysToResolution.Text = ""
  End If
End If
End Sub

'Sets up check boxes like option buttons
'If Check box 1 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption1_Click()
If Me.chkOption1.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption13.Value = 0
End Sub
'If Check box 2 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption2_Click()
If Me.chkOption2.Value = 1 Then Me.chkOption1.Value = 0
If Me.chkOption2.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption2.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption2.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption2.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption2.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption2.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption2.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption2.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption2.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption2.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption2.Value = 1 Then Me.chkOption13.Value = 0
End Sub
'If Check box 3 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption3_Click()
If Me.chkOption3.Value = 1 Then Me.chkOption1.Value = 0
If Me.chkOption3.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption3.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption3.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption3.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption3.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption3.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption3.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption3.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption3.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption3.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption3.Value = 1 Then Me.chkOption13.Value = 0
End Sub
'If Check box 4 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption4_Click()
If Me.chkOption4.Value = 1 Then Me.chkOption1.Value = 0
If Me.chkOption4.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption4.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption4.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption4.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption4.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption4.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption4.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption4.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption4.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption4.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption4.Value = 1 Then Me.chkOption13.Value = 0
End Sub
'If Check box 5 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption5_Click()
If Me.chkOption5.Value = 1 Then Me.chkOption1.Value = 0
If Me.chkOption5.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption5.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption5.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption5.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption5.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption5.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption5.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption5.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption5.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption5.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption5.Value = 1 Then Me.chkOption13.Value = 0
End Sub
'If Check box 6 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption6_Click()
If Me.chkOption6.Value = 1 Then Me.chkOption1.Value = 0
If Me.chkOption6.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption6.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption6.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption6.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption6.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption6.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption6.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption6.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption6.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption6.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption6.Value = 1 Then Me.chkOption13.Value = 0
End Sub
'If Check box 7 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption7_Click()
If Me.chkOption7.Value = 1 Then Me.chkOption1.Value = 0
If Me.chkOption7.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption7.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption7.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption7.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption7.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption7.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption7.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption7.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption7.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption7.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption7.Value = 1 Then Me.chkOption13.Value = 0
End Sub
'If Check box 8 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption8_Click()
If Me.chkOption8.Value = 1 Then Me.chkOption1.Value = 0
If Me.chkOption8.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption8.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption8.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption8.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption8.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption8.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption8.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption8.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption8.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption8.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption8.Value = 1 Then Me.chkOption13.Value = 0
End Sub
'If Check box 9 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption9_Click()
If Me.chkOption9.Value = 1 Then Me.chkOption1.Value = 0
If Me.chkOption9.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption9.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption9.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption9.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption9.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption9.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption9.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption9.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption9.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption9.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption9.Value = 1 Then Me.chkOption13.Value = 0
End Sub
'If Check box 10 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption10_Click()
If Me.chkOption10.Value = 1 Then Me.chkOption1.Value = 0
If Me.chkOption10.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption10.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption10.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption10.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption10.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption10.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption10.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption10.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption10.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption10.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption10.Value = 1 Then Me.chkOption13.Value = 0
End Sub
'If Check box 11 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption11_Click()
If Me.chkOption11.Value = 1 Then Me.chkOption1.Value = 0
If Me.chkOption11.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption11.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption11.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption11.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption11.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption11.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption11.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption11.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption11.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption11.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption11.Value = 1 Then Me.chkOption13.Value = 0
End Sub
'If Check box 12 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption12_Click()
If Me.chkOption12.Value = 1 Then Me.chkOption1.Value = 0
If Me.chkOption12.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption12.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption12.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption12.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption12.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption12.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption12.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption12.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption12.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption12.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption12.Value = 1 Then Me.chkOption13.Value = 0
End Sub
'If Check box 13 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption13_Click()
If Me.chkOption13.Value = 1 Then Me.chkOption1.Value = 0
If Me.chkOption13.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption13.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption13.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption13.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption13.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption13.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption13.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption13.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption13.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption13.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption13.Value = 1 Then Me.chkOption12.Value = 0
End Sub

'User wanted to be able to change date so automatic date function is disabled.
'Calculates the days to resolution.  The date fields need to be changed to a date field.
Private Sub chkPaid_Click()
'Me.txtDateClosed = Date
Me.cboStatus = "Closed"
If Me.cboStatus = "Closed" Then
   If IsDate(Me.txtDateClosed.Text) And IsDate(Me.txtDateReceived.Text) Then
     Me.txtDaysToResolution.Text = Format(DateDiff("d", CDate(Me.txtDateClosed.Text), CDate(Me.txtDateReceived.Text)), "##0") * -1
  Else
     Me.txtDaysToResolution.Text = ""
  End If
End If
End Sub
'User wanted to be able to change date so automatic date function is disabled.
'Calculates the days to resolution.  The date fields need to be changed to a date field.
Private Sub chkSettled_Click()
'Me.txtDateClosed = Date
Me.cboStatus = "Closed"
If Me.cboStatus = "Closed" Then
   If IsDate(Me.txtDateClosed.Text) And IsDate(Me.txtDateReceived.Text) Then
     Me.txtDaysToResolution.Text = Format(DateDiff("d", CDate(Me.txtDateClosed.Text), CDate(Me.txtDateReceived.Text)), "##0") * -1
  Else
     Me.txtDaysToResolution.Text = ""
  End If
End If
End Sub

'Adds a record
Private Sub cmdAddARecord_Click()
If datLifeComplaints.Recordset.EditMode <> dbEditNone Then
    MsgBox "Please finish your current updates before adding another new record."
Exit Sub
End If
datLifeComplaints.Recordset.AddNew
Me.cboDistributionChannel.SetFocus
End Sub
'Cancels the adding of a record
Private Sub cmdCancel_Click()
If datLifeComplaints.Recordset.EditMode = dbEditNone Then
    datLifeComplaints.UpdateControls
Else
    datLifeComplaints.Recordset.CancelUpdate
End If
End Sub

Private Sub cmdDeleteARecord_Click()
'Delete the currently displayed record
Dim intResult As Integer
If datLifeComplaints.Recordset.EditMode <> dbEditNone Then
    MsgBox "If you're currently adding a record, " _
    & "please use the Cancel Button to cancel the addition"
Exit Sub
End If

intResult = MsgBox("Are you sure you want to " _
    & "delete this record?", vbYesNo, "Delete this record")
If intResult = vbYes Then
    datLifeComplaints.Recordset.Delete
'Move so that the user sees the deleted record disappear
    datLifeComplaints.Recordset.MoveNext
    If datLifeComplaints.Recordset.EOF Then
        datLifeComplaints.Recordset.MovePrevious
    End If
End If
End Sub
'Ends the program
Private Sub cmdExit_Click()
End
End Sub
'Finds a record based on the account number
Private Sub CmdFindPolicyNo_Click()
Dim strSearchFor As String
Dim FoundFlag As Boolean
'Search for the account number
strSearchFor = InputBox("Enter an Account Number to find:")
    If Len(strSearchFor) > 0 Then
        datLifeComplaints.Recordset.MoveFirst
        FoundFlag = False
        Do While (Not FoundFlag) And (Not datLifeComplaints.Recordset.EOF)
            If (datLifeComplaints.Recordset.Fields("PolicyNumber").Value) = strSearchFor Then
                FoundFlag = True
            Else
                 datLifeComplaints.Recordset.MoveNext
            End If
        Loop
        If Not FoundFlag Then
            MsgBox "Unable to locate the requested account number.", "Not Found"
             datLifeComplaints.Recordset.MoveLast 'move so that the EOF is no longer True
        End If
    Else
        MsgBox "Must enter an account number.", , ""
    End If
End Sub
'Move to next Record
Private Sub cmdNext_Click()
datLifeComplaints.Recordset.MoveNext
Me.cboDistributionChannel.SetFocus
End Sub

'Finds a record based on the Last Name
Private Sub cmdOwnerLastName_Click()
Dim strSearchFor As String
Dim FoundFlag As Boolean
'Search for the account by owner's last name
strSearchFor = InputBox("Enter an Owner's Last Name to find:")
    If Len(strSearchFor) > 0 Then
        datLifeComplaints.Recordset.MoveFirst
        FoundFlag = False
        Do While (Not FoundFlag) And (Not datLifeComplaints.Recordset.EOF)
            If (datLifeComplaints.Recordset.Fields("ComplaintantOwnerLastName").Value) = strSearchFor Then
                FoundFlag = True
            Else
                 datLifeComplaints.Recordset.MoveNext
            End If
        Loop
        If Not FoundFlag Then
            MsgBox "Unable to locate the the Owner's Last Name.", "Not Found"
             datLifeComplaints.Recordset.MoveLast 'move so that the EOF is no longer True
        End If
    Else
        MsgBox "Must enter an Owner's Last Name.", , ""
    End If
End Sub
'Moves to previous record.
Private Sub cmdPrevious_Click()
datLifeComplaints.Recordset.MovePrevious
End Sub
'Print function.  Sets up the variable string ReportVar and the conditions for each report.
Private Sub cmdPrint_Click()
Dim ReportVar As String
If Me.chkOption1.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\All Open Life Complaints By Distribution Channel.rpt"
If Me.chkOption2.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\Life Complaints Closed After The Month Plus Complaints Still Open.rpt"
If Me.chkOption3.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\Life Complaints Closed By Distribution Channel.rpt"
If Me.chkOption4.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\Life Complaints Closed During The Month By Distribution Channel.rpt"
If Me.chkOption5.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\Life Complaints Duplicate Records.rpt"
If Me.chkOption6.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\Life Complaints From New York.rpt"
If Me.chkOption7.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\Life Complaints Received and Closed.rpt"
If Me.chkOption8.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\Life Complaints Received and Open.rpt"
If Me.chkOption9.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\Life Services - Complaint Log.rpt"
If Me.chkOption10.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\Summary of all Life Complaints Received in Reporting Period.rpt"
If Me.chkOption11.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\Summary of All Life Complaints Received Prior to the Current Month.rpt"
If Me.chkOption12.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\Life Complaint Descriptions and Codes.rpt"
If Me.chkOption13.Value = 1 Then ReportVar = "G:\Common\LifeGeneralServices\PHSManagement\Complaints\Reports\Life Distribution Channels and Codes.rpt"
'This is the code that displays the report on the screen ready to print, refresh, or export.
With Report1
.WindowShowRefreshBtn = True
.ReportFileName = ReportVar
.Action = 1
End With
End Sub
'Updates the record after an edit.
Private Sub cmdUpdate_Click()
If datLifeComplaints.Recordset.EditMode = dbEditAdd Then
    datLifeComplaints.Recordset.Update
Else
    datLifeComplaints.Recordset.Edit
    datLifeComplaints.Recordset.Update
End If
End Sub

'Sets up the counting of the records and displays the count in the data control.
Private Sub datLifeComplaints_Reposition()
datLifeComplaints.Caption = datLifeComplaints.Recordset.AbsolutePosition + 1 & " of " & _
datLifeComplaints.Recordset.RecordCount
End Sub
'Initializes the count
Private Sub Form_Activate()
datLifeComplaints.Recordset.MoveLast
datLifeComplaints.Recordset.MoveFirst
End Sub

'Login Form:

Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Author:
'Life Complaints System
'November 7, 2003
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public LoginSucceeded As Boolean
'Cancels the login process
Private Sub cmdCancel_Click()
     If vbOK = MsgBox("Are you sure you want to exit?", vbOKCancel) Then
        Unload Me
        End
    Else
        txtUserID.SetFocus
    End If
End Sub
'Completes the login process
Private Sub cmdOK_Click()
Static intBadLogins As Integer
Dim g_strUser As String
'Set Variable equal to Text Value of txtUserID Textbox
g_strUser = UCase(txtUserID.Text)
'Set Index Property of Recordset to Primary Key---necessary for Seek Operation
datUsers.Recordset.Index = "PrimaryKey"
'Seek a record in the Users Table with that UserID
datUsers.Recordset.Seek "=", UCase(txtUserID.Text)
If datUsers.Recordset.NoMatch = True Then
    MsgBox "You are not an authorized user..."
    Unload Me
    End
End If

'If found, check the value of the Password in the Recordset
If UCase(txtPassword.Text = UCase(datUsers.Recordset("Password").Value)) Then
    MsgBox g_strUser & ", you are successfully Logged On. Please proceed..."
    Unload Me
   
Else
    'Sets a limit of 3 trys to login then refers you to the administrator
    intBadLogins = intBadLogins + 1
    If intBadLogins = 3 Then
        MsgBox "Contact you administrator."
        Unload Me
        End
    Else
        'Chechs to see if the password is blank.
        txtPassword.Text = ""
        txtPassword.SetFocus
        MsgBox "Your password is incorrect.  Please Try Again..."
    End If
End If
End Sub

Private Sub datUsers_Validate(Action As Integer, Save As Integer)
If datUsers.Recordset.EditMode <> dbEditNone Then
    If txtUserID.Text = "" Then
        MsgBox "UserID must be entered."
        txtUserID.SetFocus
        Save = False
        Action = vbDataActionCancel
        Exit Sub
    End If
    If txtPassword = "" Then
        MsgBox "Password must be entered."
        txtPassword.SetFocus
        Save = False
        Action = vbDataActionCancel
        Exit Sub
    End If
End If
End Sub

Private Sub txtPassword_KeyPress(KeyAscii As Integer)
If KeyAscii >= 97 And KeyAscii <= 122 Then
    KeyAscii = KeyAscii - 32
End If
End Sub

Private Sub txtUserID_KeyPress(KeyAscii As Integer)
If KeyAscii >= 97 And KeyAscii <= 122 Then
    KeyAscii = KeyAscii - 32
End If
End Sub

'Module:

Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Author:
'Life Complaints System
'November 7, 2003
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Main()
Dim X As Long, P As Integer
'Splash screen appears
Splash.Show
For X = 1 To 1000000
    P = DoEvents()
    Next X
Unload Splash
Load frmInformation
frmInformation.Show
MsgBox "You are authorized to use this system for approved purposes only.  " _
& "Use for any other purpose is prohibited.  All transactional records, " _
& "reports, e-mail, software, and other data generated by or residing upon " _
& "this System are the property of the Company and may be used by the Company " _
& "for any purpose.  Authorized and unauthorized activities may be monitored."
Load frmLogin
frmLogin.Show
End Sub

'Splash Form:

Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Author:
'Life Complaints System
'November 7, 2003
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Form_KeyPress(KeyAscii As Integer)
    Unload Me
End Sub

Private Sub Form_Load()
    lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
    lblProductName.Caption = App.Title
End Sub

Private Sub Frame1_Click()
    Unload Me
End Sub

0
Comment
Question by:dick3677
14 Comments
 
LVL 3

Expert Comment

by:ketapillar
ID: 9726425
These lines could be changed....

Private Sub cboComplaintDescription_Validate(Cancel As Boolean)
If Me.cboComplaintDescription = "Life-Agent Conduct" Then Me.cboComplaintDescriptionCodes = "CD10"
If Me.cboComplaintDescription = "Life-Death Claim" Then Me.cboComplaintDescriptionCodes = "CD11"
If Me.cboComplaintDescription = "Life-General Customer Service" Then Me.cboComplaintDescriptionCodes = "CD12"
If Me.cboComplaintDescription = "Life-Not Taken" Then Me.cboComplaintDescriptionCodes = "CD13"
If Me.cboComplaintDescription = "Life-Policy Performance" Then Me.cboComplaintDescriptionCodes = "CD14"
If Me.cboComplaintDescription = "Life-Surrender" Then Me.cboComplaintDescriptionCodes = "CD15"
End Sub
'Sets the distribution codes.
Private Sub cboDistributionChannel_Validate(Cancel As Boolean)
If Me.cboDistributionChannel = "Life-Citibank" Then Me.cboDistributionCodes = "DC10"
If Me.cboDistributionChannel = "Life-Citistreet/Direct Markets" Then Me.cboDistributionCodes = "DC11"
If Me.cboDistributionChannel = "Life-Smith Barney" Then Me.cboDistributionCodes = "DC12"
If Me.cboDistributionChannel = "Life-Prudential" Then Me.cboDistributionCodes = "DC13"
If Me.cboDistributionChannel = "Life-Independent Agents" Then Me.cboDistributionCodes = "DC14"
End Sub

to

Select Case cboComplaintDescription
    Case "Life-Agent Conduct"
        cboDistributionCodes = "DC10"
    Case "Life-Citistreet/Direct Markets"
        cboDistributionCodes = "DC11"
    ... and so on
End Select


Also instead of checkboxes (which allow multiple) why don't you use radio buttons?  (Will shrink the code tremendously)

This...

'If Check box 1 is checked then all the rest are unchecked (1 = True And 0 = False).
Private Sub chkOption1_Click()
If Me.chkOption1.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption13.Value = 0
End Sub

Would be handled automatically...

Back on the problem... do you know what line it's actually erroring out on?
0
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9727051
Make sure you include all the required dll/ocx on the target machine.

~ fantasy ~
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9727082
while I agree with ketapillar about the use of Radio Buttons rather than check boxes,

code like this:
Private Sub chkOption1_Click()
If Me.chkOption1.Value = 1 Then Me.chkOption2.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption3.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption4.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption5.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption6.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption7.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption8.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption9.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption10.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption11.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption12.Value = 0
If Me.chkOption1.Value = 1 Then Me.chkOption13.Value = 0
End Sub
 can be simplified to:

If Me.chkOption1.Value = 1 then
   Me.chkOption2.Value = 0
   Me.chkOption3.Value = 0
   Me.chkOption4.Value = 0
   Me.chkOption5.Value = 0
   Me.chkOption6.Value = 0
   Me.chkOption7.Value = 0
   Me.chkOption8.Value = 0
   Me.chkOption9.Value = 0
   Me.chkOption10.Value = 0
   Me.chkOption11.Value = 0
   Me.chkOption12.Value = 0
   Me.chkOption13.Value = 0
end if

is this in Access, or in VB 6.

In VB 6 , you could greatly simplify this code with control arrays (which are NOT supported in Access VBA).

AW
0
 

Expert Comment

by:twili
ID: 9730429
Why not make the chk-boxes into a controlarray, then the code will be even sompler. (best would of course be to use radio buttons)

If Me.chkOption1.Value = 1 then
   Me.chkOption2.Value = 0
   Me.chkOption3.Value = 0
   Me.chkOption4.Value = 0
   Me.chkOption5.Value = 0
   Me.chkOption6.Value = 0
   Me.chkOption7.Value = 0
   Me.chkOption8.Value = 0
   Me.chkOption9.Value = 0
   Me.chkOption10.Value = 0
   Me.chkOption11.Value = 0
   Me.chkOption12.Value = 0
   Me.chkOption13.Value = 0
end if

would become:
If Me.chkOption(1).Value = 1 then
  for i = 2 to 13
    Me.chkOption(i).Value = 0
  next i
end if
 
/O.
0
 

Author Comment

by:dick3677
ID: 9730997
I originally registered dao360.dll because dao350.dll was not on the machine.  That is the first time I got the error.  I then unregistered the dao360.dll and registered the dao350.dll.  I still got the same erro.  I also registered the Crystl32.OCX (Crystal Control).  This was done on all target machines.  All total I have 2 development machines and the program works on both.  One is running Windows 2000 sp3 and the other Windows XP.  There were 5 user machines using Windows 2000 sp3 and only one out of the 4 worked.  My two development machines both have VB6 on them, and the users' machine that works does not.  I duplicated the error on my development machines by unregistering the dao350.dll.  After re-registering the dao350.dll and recompiling the program it cured the error but not on the users' machine.  I don't know what line the program stops on because I can't debug the program on the users' machine.  This is all coded in VB6 sp4 and sp5.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Expert Comment

by:EmcoMaster
ID: 9736708
Radio buttons...  Put them all in one frame, and the entire if/then becomes automated... only one at a time is allowed, and ALL the extra code goes away!


Dick3677...  forgive my asking the obvious...  is dao350 (or dao360, for that matter) part of your distribution package?
It sounds like you should get the latest and greatest on your development machines, verify that all is well, then be sure all of your users get the same version.
0
 

Author Comment

by:dick3677
ID: 9739067
From my research both dao360.dll and dao350.dll ran be registered and exist on the same machine.  Both are registered.  The machines all had dao360.dll and not dao350.dll so I registered.  This produced the error Class not registered.  Looking for object with CLSID:{00000010-0000-0010-8000-00AA006D2EA4} which is associated with dao350.dll.  I copied the dao350.dll from my machine, unregistered dao360.dll and registered dao350.dll.  This produced an error Class not registered.  Looking for object with CLSID:{00000100-...} which is associated with dao360.dll.  I reregister dao360.dll and cured both these errors then I got the error Run-time error '91': Object variable or With block variable not set.  I know this error is connected with the dao350.dll because I recreated the error on one of my machines and corrected the problem when I reregistered the correct .dll (dao350.dll).  No matter what I do with the 4 machines I am having trouble with I still get the error Run-time error '91': Object variable or With block variable not set.
0
 
LVL 3

Expert Comment

by:ketapillar
ID: 9741533
Here's an idea...

If possible install VB6 on one of the machines that's giving you the error.  Run it in debug mode on that machine and when the error pops out you will have the line it's erroring out on.  Generally the "Object variable or With block variable not set" error is something that makes me slap my forhead and say "Doh!!!" when I figure out what it is...  Getting the actual line should tell you exactly what is going on.

I noticed that you were using crystal reports.  Which version?  I'm using 8.5 and have noticed wierd errors popping up (using crviewer??.dll) where code previously worked.  Mostly on "Unload Me and SetFocus" areas.  What's really wierd about them (I ended up commenting them out to keep the program live) was that running in debug mode.  It would error out and halt at the line of the error.  Then when I pressed f5 (run) it would execute as normal with no error.  I can't remember what the exact error message was though... Might have been the same.  In some instances of trying to unload the report it would give me a stack error and VB and program would crash with the... Send this information to microsoft due to illegal operation error.  Which stopped me from quick coding (coding while program was running) due to me losing everything so many times.
0
 

Author Comment

by:dick3677
ID: 9741970
Sounds like you are using the RDC in Crystal.  I don't care for that.  I am using Crystal 8.5 and I use the Crystal Report Control and embed the control in the application.  I am usually error free.  

I can't put VB6 on the machine I only have one license and the company does not support VB6 so I'm on my own.  I would be willing to bet you the 500 points that if I put VB6 on the machine there would be no error.  I am guessing at best but I believe that because I registered dao360.dll first on those machines that is why I'm getting the Run-time error '91': Object variable or With block variable not set even though I did unregister dao360.dll but I am not certain.
0
 
LVL 5

Accepted Solution

by:
RainUK earned 500 total points
ID: 9787671
Okay, in terms of debugging you need to know which object has not been instantiated, before one of its methods is being called.

What I suggest.... is you get some line numbering tool, or DIY. Then add error handling routines to the most likely Subroutines which may be causing the error. Now in your error handling routine, you could throw a msgbox and in the line stick the code:

Erl()

This will return the line number that the error occured on. e.g

Private Sub MySubroutine

On error goto ErrHandler

Exit Sub
ErrHandler:
Msgbox "Error :" & Err.Number & vbcr & Err.Description & vbcr & "MySubroutine - LineNumber = " & Erl(), vbCritical+vbOkOnly
Exit Sub

At least you will now know what line it is blowing up on and to which object it is trying to reference.

It sounds to me as if your code is firing some event out of logical sequence and re-referencing a part of your code without running the instantiation code for the object, which it cannot execute a method for.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 10537275
Moderator, my recommended disposition is:

    Accept RainUK's comment(s) as an answer.

Dan Rollins -- EE database cleanup volunteer
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now