Re: Please Help. Need INfo
Try the next:
Remove from the 'Command3_Click' event the next code
Code:
Label1.Caption = Income1.SelectedItem
Label2.Caption = Income1.SelectedItem.SubItems(1)
Label3.Caption = Income1.SelectedItem.SubItems(2)
Label4.Caption = Income1.SelectedItem.SubItems(3)
In the 'Income1_ItemClick' event write the next code
Code:
Label1.Caption = Item.Text
Label2.Caption = Item.SubItems(1)
Label3.Caption = Item.SubItems(2)
Label4.Caption = Item.SubItems(3)
I seems to me that you are not selecting the row in a proper way
Re: Please Help. Need INfo
Re: Please Help. Need INfo
Hey, jggtz
I did what you said and it says:
Complile Error:
Procedure Declaration does not match description of event or procedure having the same name.
Could you please advise.
Re: Please Help. Need INfo
Post the code and say in which line is the error
Re: Please Help. Need INfo
Private Sub Income1_ItemClick()
Label1.Caption = Item.Text
Label2.Caption = Item.SubItems(1)
Label3.Caption = Item.SubItems(2)
Label4.Caption = Item.SubItems(3)
End Sub
Its in line 1 the error appears.. and yet whenever i click on the listview with this in the code, it automatically goes to this part of code??
Re: Please Help. Need INfo
In post #1 You did say that Income1 is a ListView control
The right syntax por the ItemClick event procedure is :
Code:
Private Sub Income1_ItemClick(ByVal Item As MSComctlLib.ListItem)
and You even don't have to write it, just select and use it
... and yes, the click on any row in the listview is the way to select the row that you're going to use a filter in the Find and Delete
Re: Please Help. Need INfo
Ahh.
I done that and its selecting the listview item, and placing it in the labels... but it still deletes the first item?
Code 1:
Private Sub Income1_ItemClick(ByVal Item As MSComctlLib.ListItem)
Label1.Caption = Item.Text
Label2.Caption = Item.SubItems(1)
Label3.Caption = Item.SubItems(2)
Label4.Caption = Item.SubItems(3)
End Sub
Code 2:
Private Sub Command3_Click()
If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "Income = '" & Label1.Caption & "'"
If Adodc1.Recordset.Fields!Date = Label2.Caption And Adodc1.Recordset.Fields!Amount = Label3.Caption And Adodc1.Recordset.Fields!Frequency = Label4.Caption Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveFirst
Else
MsgBox "Not Item Found", vbOKOnly + vbExclamation, "Error27"
End If
End Sub
Any Ideas?
Re: Please Help. Need INfo
Try the next code
Code:
Private Sub Command3_Click()
If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "Income = '" & Label1.Caption & "'"
If Adodc1.EOF = False Then
If Adodc1.Recordset.Fields!Date = CDate(Label2.Caption) And _
Adodc1.Recordset.Fields!Amount = CDbl(Label3.Caption) And _
Adodc1.Recordset.Fields!Frequency = Label4.Caption Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveFirst
End If
Else
MsgBox "Not Item Found", vbOKOnly + vbExclamation, "Error27"
End If
End Sub
If the field "Amount" isn't double then change to right conversion
function, same applies to field Frequency
Re: Please Help. Need INfo
Hey, done all that and it still deletes the first in the list.. and if i click command 3 without anything selected it also deletes one at a time from the top down??
But i can select the third and it will delete first and second before it deletes the third.
I will look through the rest of my Code.. it must be something in there causeing this.
Unless you have another idea?
Re: Please Help. Need INfo
Quote:
and if i click command 3 without anything selected it also deletes one at a time from the top down
Code:
Private Sub Command3_Click()
If Trim(Label1.Caption) = "" Then
Exit Sub
End If
If Adodc1.Recordset.BOF = False Then
Adodc1.Recordset.MoveFirst
End If
Adodc1.Recordset.Find "Income = '" & Label1.Caption & "'"
If Adodc1.EOF = False Then
If Adodc1.Recordset.Fields!Date = CDate(Label2.Caption) And _
Adodc1.Recordset.Fields!Amount = CDbl(Label3.Caption) And _
Adodc1.Recordset.Fields!Frequency = Label4.Caption Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveFirst
Label1.Caption = ""
Label2.Caption = ""
Label3.Caption = ""
Label4.Caption = ""
End If
Else
MsgBox "Not Item Found", vbOKOnly + vbExclamation, "Error27"
End If
End Sub
Quote:
Unless you have another idea
Post all your form's code and we'll see...
Re: Please Help. Need INfo
Hey, full code below... bit of a mess and prob sum bad programming... but its doing what i want so far.. apart from this deleteing issue.
Code:
Option Explicit
Dim I As Integer
Dim Incom As String
Dim Amoun As Currency
Dim Dat As Date
Dim Freq As String
Dim CurTot As Currency
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
Incom = InputBox("Please Enter The Income Type." & Chr(13) & Chr(13) & "Example: Wages, Income Support, JSA etc..", "Add New Income")
Amoun = InputBox("Please Enter The Amount You Recieve" & Chr(13) & Chr(13) & "Format: ###.## etc..", "Add New Income")
Dat = InputBox("Please Enter The Date You Next Recieve This Payment" & Chr(13) & Chr(13) & "Format: ##/##/####", "Add New Income")
Freq = InputBox("Please Enter How Frequently You Recieve This Payment" & Chr(13) & "Use Code Below" & Chr(13) & Chr(13) & "D = Daily" & Chr(13) & "W = Weekly" & Chr(13) & "F = Every Two Weeks" & Chr(13) & "M = Monthly" & Chr(13) & "Y = Yearly", "Add New Income")
Label1.Caption = Incom
Label2.Caption = Dat
Label3.Caption = Amoun
If Freq = "D" Then Label4.Caption = "Daily"
If Freq = "W" Then Label4.Caption = "Weekly"
If Freq = "F" Then Label4.Caption = "Fort Nightly"
If Freq = "M" Then Label4.Caption = "Monthly"
If Freq = "Y" Then Label4.Caption = "Yearly"
Adodc1.Recordset.Update
Income1.ListItems.Clear
Form_Load
End Sub
Private Sub Command3_Click()
If Trim(Label1.Caption) = "" Then
Exit Sub
End If
If Adodc1.Recordset.BOF = False Then
Adodc1.Recordset.MoveFirst
End If
Adodc1.Recordset.Find "Income = '" & Label1.Caption & "'"
If Adodc1.Recordset.EOF = False Then
If Adodc1.Recordset.Fields!Date = CDate(Label2.Caption) And _
Adodc1.Recordset.Fields!Amount = CDbl(Label3.Caption) And _
Adodc1.Recordset.Fields!Frequency = Label4.Caption Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveFirst
Label1.Caption = ""
Label2.Caption = ""
Label3.Caption = ""
Label4.Caption = ""
End If
Else
MsgBox "Not Item Found", vbOKOnly + vbExclamation, "Error27"
End If
End Sub
Private Sub Command5_Click()
Dim lngIndex As Long
CurTot = 0
If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MoveFirst
For lngIndex = 1 To Adodc1.Recordset.RecordCount
CurTot = CurTot + Adodc1.Recordset.Fields!Amount
Label5.Caption = CurTot
If CurTot < 1000 Then
Label5.Caption = Format(Label5.Caption, "000.00")
Else
Label5.Caption = Format(Label5.Caption, "0000.00")
End If
Adodc1.Recordset.MoveNext
Next
£££Deck.Label1.Caption = "Income:"
£££Deck.Label1.Caption = £££Deck.Label1.Caption & " " & "£" & Label5.Caption
End Sub
Private Sub Form_Load()
Column_Setup
Data_Setup
End Sub
Private Sub Data_Setup()
If Adodc1.Recordset.RecordCount > 0 Then
I = 1
Adodc1.Recordset.MoveFirst
With Adodc1.Recordset
Do Until .EOF
Income1.ListItems.Add , , .Fields!Income
Income1.ListItems(I).SubItems(1) = .Fields!Date
Income1.ListItems(I).SubItems(2) = "£" & .Fields!Amount
Income1.ListItems(I).SubItems(3) = .Fields!Frequency
.MoveNext
I = I + 1
Loop
End With
Else
MsgBox "No Items In Database"
End If
End Sub
Private Sub Column_Setup()
With Income1
.ColumnHeaders.Clear
.ColumnHeaders.Add , , "Income", .Width * 0.25
.ColumnHeaders.Add , , "Date", .Width * 0.25
.ColumnHeaders.Add , , "Amount", .Width * 0.25
.ColumnHeaders.Add , , "Frequency", .Width * 0.25
End With
End Sub
Private Sub Income1_ItemClick(ByVal Item As MSComctlLib.ListItem)
Label1.Caption = Item.Text
Label2.Caption = Item.SubItems(1)
Label3.Caption = Item.SubItems(2)
Label4.Caption = Item.SubItems(3)
End Sub