b24 sofwtares
New member
- Local time
- Today, 18:33
- Joined
- Aug 28, 2024
- Messages
- 2
hi, i have listbox with some columns. on a form, i have insert a pie chat. i wan that when i select a row in the listbox, it should display me the pie chat with values from the columns 5 and 6 of the row selected. here is the complete code
Private Sub Years_listbox_Click()
If Me.Years_listbox.ListIndex <> -1 Then
Me.Modify_year_btn.Visible = True
Me.Chart50.Visible = True
Me.Chart50.ChartTitle = "Revenues vs Expenses " & Me.Years_listbox.Column(0, Me.Years_listbox.ListIndex)
Dim selectedItem As Variant
selectedItem = Me.Years_listbox.Column(4, Me.Years_listbox.ListIndex) ' column 5
Dim revenues As String
revenues = selectedItem
revenues = CDbl(Replace(revenues, ",", ""))
selectedItem = Me.Years_listbox.Column(5, Me.Years_listbox.ListIndex) ' column 6
Dim expenses As String
expenses = selectedItem
expenses = CDbl(Replace(expenses, ",", ""))
'THE CODE TO DISPLAY THE PIE CHART SHOULD GO HERE
Me.Chart50.Visible = True
Else
If Me.Years_listbox.ListIndex = -1 Then
Me.Modify_year_btn.Visible = False
End If: End If
End Sub
Private Sub Years_listbox_Click()
If Me.Years_listbox.ListIndex <> -1 Then
Me.Modify_year_btn.Visible = True
Me.Chart50.Visible = True
Me.Chart50.ChartTitle = "Revenues vs Expenses " & Me.Years_listbox.Column(0, Me.Years_listbox.ListIndex)
Dim selectedItem As Variant
selectedItem = Me.Years_listbox.Column(4, Me.Years_listbox.ListIndex) ' column 5
Dim revenues As String
revenues = selectedItem
revenues = CDbl(Replace(revenues, ",", ""))
selectedItem = Me.Years_listbox.Column(5, Me.Years_listbox.ListIndex) ' column 6
Dim expenses As String
expenses = selectedItem
expenses = CDbl(Replace(expenses, ",", ""))
'THE CODE TO DISPLAY THE PIE CHART SHOULD GO HERE
Me.Chart50.Visible = True
Else
If Me.Years_listbox.ListIndex = -1 Then
Me.Modify_year_btn.Visible = False
End If: End If
End Sub