ive attached my programme herewith.

the report doesn't function properly

in the tab 2 i have put a command button which generates the report

could you please help

Recommended Answers

All 2 Replies

The code after the Exit Sub cannot be reached at all. the procedure exits at that point and the code which u have written below the Error Handler Label is never reached. That's why the error.

Private Sub Form_Load()

    On Error GoTo Form_Load_Error

    Set con = New ADODB.Connection
    con.Open "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & App.Path & "\Office Utilization.mdb"
    Call FillLocation
    Call Filllocation2
    
Form_Load_Done:
    Exit Sub

Form_Load_Error:
    MsgBox "An Error has occured in Procedure Form_Load." & vbCrLf & vbCrLf & Err.Number & " : " & Err.Description
    Resume Form_Load_Done



  Dim i As Integer
  
  ' Get a recordset to use with the report
  Set rs = CreateRecords
  
  ' Populate Comboboxes
  For i = 0 To cboSort.Count - 1
    With cboSort(i)
      .AddItem "(None)"
      .AddItem "locname"
      .AddItem "floorname"
      .AddItem "seatno"
      .AddItem "empname"
      .ListIndex = 0
    End With
  Next

End Sub

Please correct this procedure. It should be like this.

Private Sub Form_Load()

    On Error GoTo Form_Load_Error

    Set con = New ADODB.Connection
    con.Open "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & App.Path & "\Office Utilization.mdb"
    Call FillLocation
    Call Filllocation2
    
    Dim i As Integer
  
    ' Get a recordset to use with the report
    Set rs = CreateRecords

    ' Populate Comboboxes
    For i = 0 To cboSort.Count - 1
        With cboSort(i)
            .AddItem "(None)"
            .AddItem "locname"
            .AddItem "floorname"
            .AddItem "seatno"
            .AddItem "empname"
            .ListIndex = 0
        End With
    Next

Form_Load_Done:
    Exit Sub

Form_Load_Error:
    MsgBox "An Error has occured in Procedure Form_Load." & vbCrLf & vbCrLf & Err.Number & " : " & Err.Description
    Resume Form_Load_Done

End Sub

Hope this solves ur problem

Regards
Shaik Akthar

thanks a lot

i'll try it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.