dellehurley
Board Regular
- Joined
- Sep 26, 2009
- Messages
- 171
- Office Version
- 365
- Platform
- Windows
Hi
I have listbox in a userforms which select a row in a database. Previously the click event fired when I clicked, but it has stopped.
This is the click event code and below that is the userform reset code. Any ideas of what I have changed or why it stopped working?
Dannielle
I have listbox in a userforms which select a row in a database. Previously the click event fired when I clicked, but it has stopped.
- It runs one upon entry to the userform but not again.
- I have another userform in the same workbook which works the same way and it continues to work correctly.
- I have removed any enabled events=false in the document. And run the line enabled events=true
Dannielle
VBA Code:
Private Sub lstDatabase_Click()
Dim SerialNo As String
'Dim StartDt As String
Dim Payee As String
Dim Amt As Currency
Dim RowNo As Long
Dim NoEnd As Boolean
Application.EnableEvents = True
With Me.lstDatabase
RowNo = Val(.ListIndex + 1)
If RowNo > 1 Then
.ColumnCount = 14
.ColumnWidths = "55,50,50,25,50,50,100,80,70,0,0,0,0,0"
Call EnterFormColour(RowNo)
Payee = .Column(6)
Amt = .Column(8)
.List = BgtWs.Range("A" & RowNo, "N" & RowNo).Value
.List(0, 0) = Format(BgtWs.Range("A" & RowNo), "dd/mm/yyyy")
.List(0, 1) = Format(BgtWs.Range("B" & RowNo), "dd/mm/yyyy")
If BgtWs.Range("C" & RowNo) = "True" Then
.List(0, 2) = "True"
Else: .List(0, 2) = "False"
End If
.List(0, 11) = Format(BgtWs.Range("L" & RowNo), "dd/mm/yyyy")
.List(0, 8) = Format(BgtWs.Range("I" & RowNo), "$#,##0.00")
If Me.txtAmount.Value <> "" Then
Me.cmdEdit.Caption = ""
Else: Me.cmdEdit.Caption = Payee & " / $" & Amt
End If
Me.txtRowNumber.Value = RowNo + 1
Else: Me.cmdEdit.Caption = ""
End If
End With
End Sub
VBA Code:
Sub Reset_Enter()
Dim DbLastRow As Long
Dim BgtLastRow As Long
Dim Payee As String
Dim aLastRow As Long
Dim cLastRow As Long
Dim TomorrowDt As Date
Dim i As Long
DbLastRow = DbWs.Cells(DbWs.Rows.Count, "A").End(xlUp).Row
BgtLastRow = BgtWs.Cells(BgtWs.Rows.Count, "A").End(xlUp).Row
cLastRow = PopWs.Cells(PopWs.Rows.Count, "C").End(xlUp).Row
aLastRow = PopWs.Cells(PopWs.Rows.Count, "A").End(xlUp).Row
TomorrowDt = Format(TodayDt + 1, "dd/mm/yyyy")
PopWs.Range("C2:C" & cLastRow).Name = "Payees"
PopWs.Range("A2:A" & aLastRow).Name = "Categories"
If BgtLastRow = 1 Then
BgtWs.Range("A2:N2").Name = "BudgetList"
Else
BgtWs.Range("A2:N" & BgtLastRow).Name = "BudgetList"
End If
If DbLastRow = 1 Then
DbWs.Range("A2:A2").Name = "ACol"
DbWs.Range("E2:E2").Name = "ECol"
DbWs.Range("A1:G2").Name = "AllDatabase"
DbWs.Range("A2:G2").Name = "Database"
Else
DbWs.Range("A2:A" & DbLastRow).Name = "ACol"
DbWs.Range("E2:E" & DbLastRow).Name = "ECol"
DbWs.Range("A1:G" & DbLastRow).Name = "AllDatabase"
DbWs.Range("A2:G" & DbLastRow).Name = "Database"
End If
BgtWs.Range("ALL_ONE").Value = ""
SchWs.Cells(1, 1).Value = "" 'date held when start date given is in the past and next date not supplied until Sumbit Rpt cal
PopWs.Range("Q1").Clear
DbWs.Range("AllDatabase").Sort Key1:=DbWs.Range("A:A"), order1:=xlAscending, Header:=xlYes
PopWs.Range("Categories").Sort Key1:=PopWs.Range("Categories"), order1:=xlAscending, Header:=xlYes
PopWs.Range("Payees").Sort Key1:=PopWs.Range("C:C"), order1:=xlAscending, Header:=xlYes
With frmEnter
.BorderColor = RGB(0, 0, 0)
.chkVary.Value = False
.txtAmount.Value = ""
.cmdEdit.Caption = ""
.txtRowNumber = ""
.txtEndDt = ""
.chkCat.Value = False
.chkPay.Value = False
.chkNoEnd.Value = False
.cmbFreq.BackColor = RGB(255, 255, 255)
.cmbFreq.Value = ""
.cmbFreq.AddItem "Once Only"
.cmbFreq.AddItem "Daily"
.cmbFreq.AddItem "Weekly"
.cmbFreq.AddItem "Fortnightly"
.cmbFreq.AddItem "Monthly"
.cmbFreq.AddItem "Quarterly"
.cmbFreq.AddItem "Tri Annually"
.cmbFreq.AddItem "Bi Annually"
.cmbFreq.AddItem "Annually"
.cmbCategory.Value = ""
.cmbCategory.BackColor = RGB(255, 255, 255)
.cmbCategory.List = PopWs.Range("Categories").Value
.cmbPayee.Value = ""
.cmbPayee.BackColor = RGB(255, 255, 255)
If cLastRow > 2 Then
.cmbPayee.List = PopWs.Range("Payees").Value
End If
.optBill.Value = False
.optDeposit.Value = False
.txtRepeat.Value = ""
Call EnterColour
With .DTPickersStart
.Value = TodayDt
.CustomFormat = "dd/mm/yyyy"
End With
With .DTPickerEnd
.CheckBox = True
.Value = Null
.CustomFormat = "dd/mm/yyyy"
.MinDate = TomorrowDt
End With
With .lstBgtHeader
.ColumnCount = 14
.ColumnWidths = "55;50;50;25;50;50;100;80;70;0;0;0;0;0"
.List = BgtWs.Range("A1:N1").Value
End With
With .lstDatabase
.ColumnCount = 14
.ColumnWidths = "55;50;50;25;50;50;100;80;70;0;0;0;0;0"
If BgtLastRow > 1 Then
.List = BgtWs.Range("BudgetList").Value
Else
.List = BgtWs.Range("A2:N2").Value
End If
For i = 0 To .ListCount - 1
.List(i, 0) = Format(.List(i, 0), "dd/mm/yyyy")
.List(i, 1) = Format(.List(i, 1), "dd/mm/yyyy")
.List(i, 11) = Format(.List(i, 11), "dd/mm/yyyy")
.List(i, 8) = Format(.List(i, 8), "$#,##0.00")
If .List(i, 2) = "True" Then
.List(i, 2) = "True"
ElseIf i = 0 Then
.List(i, 2) = ""
Else: .List(i, 2) = "False"
End If
Next
End With
End With
End Sub