PC Review


Reply
Thread Tools Rate Thread

Deleting row from entry in listbox on a form error

 
 
Jennifer
Guest
Posts: n/a
 
      30th Nov 2007
I am getting an error
Object does not support this property or method

Here is the code i am trying to use
Private Sub cmdDelete_Click()

If lstData.ListIndex = -1 Then Exit Sub
' Dim Index As String
Dim msg As String
Index = txtDataID.Text
msg = lstData.List(lstData.ListIndex, 1)
msg = msg & " " & lstData.List(lstData.ListIndex, 2)
msg = msg & " " & lstData.List(lstData.ListIndex, 3)
msg = msg & " " & lstData.List(lstData.ListIndex, 4)
If MsgBox(msg, vbYesNo + vbDefaultButton2, "DELETE #" & Index & " from "
& cboRation) = vbYes Then
RemoveItem Index
End If
End Sub
Private Sub RemoveItem(Index As String)
Dim found As Range
Dim ok As Boolean
With Worksheets("Rations")
For Each found In .Range(.Range("A2"), .Range("A2").End(xlDown))
If found = Index Then
ok = True
Exit For
End If
Next
End With
If ok Then
found.Resize(, 6).Delete xlShiftUp
LoadData
Else
MsgBox Index & " not found!"
End If
End Sub
--
Thank you,

Jennifer
 
Reply With Quote
 
 
 
 
John Bundy
Guest
Posts: n/a
 
      30th Nov 2007
I tried to recreate your form, but i'm not getting any errors. Where are you
getting the error? The only thing that sticks out to me is you show this
If ok Then
found.Resize(, 6).Delete xlShiftUp
LoadData
Else
but don't show the code for LoadData
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Jennifer" wrote:

> I am getting an error
> Object does not support this property or method
>
> Here is the code i am trying to use
> Private Sub cmdDelete_Click()
>
> If lstData.ListIndex = -1 Then Exit Sub
> ' Dim Index As String
> Dim msg As String
> Index = txtDataID.Text
> msg = lstData.List(lstData.ListIndex, 1)
> msg = msg & " " & lstData.List(lstData.ListIndex, 2)
> msg = msg & " " & lstData.List(lstData.ListIndex, 3)
> msg = msg & " " & lstData.List(lstData.ListIndex, 4)
> If MsgBox(msg, vbYesNo + vbDefaultButton2, "DELETE #" & Index & " from "
> & cboRation) = vbYes Then
> RemoveItem Index
> End If
> End Sub
> Private Sub RemoveItem(Index As String)
> Dim found As Range
> Dim ok As Boolean
> With Worksheets("Rations")
> For Each found In .Range(.Range("A2"), .Range("A2").End(xlDown))
> If found = Index Then
> ok = True
> Exit For
> End If
> Next
> End With
> If ok Then
> found.Resize(, 6).Delete xlShiftUp
> LoadData
> Else
> MsgBox Index & " not found!"
> End If
> End Sub
> --
> Thank you,
>
> Jennifer

 
Reply With Quote
 
Jennifer
Guest
Posts: n/a
 
      30th Nov 2007
It is not showing where i am having the error just that i just put that part
in so i assume it has to be in there.

Here is the load data code that works in my update code and lstbox click code.
Private Sub LoadData()
With lstData
..Clear
Ration = cboRation.Value
For Index = 2 To source.Rows.Count
If Ration = source.Cells(Index, 2) Then
.AddItem source.Cells(Index, 1) 'id
' .List(.ListCount - 1, 2) = source.Cells(index, eBoxes.Date1)
.List(.ListCount - 1, 2) = source.Cells(Index, eBoxes.Ingredient)
.List(.ListCount - 1, 3) = source.Cells(Index, eBoxes.Percent_of_ration)
' .List(.ListCount - 1, 5) = source.Cells(index, eBoxes.Ration_ID)
.List(.ListCount - 1, 4) = source.Cells(Index, eBoxes.Pounds)
End If
Next
End With
End Sub
--
Thank you,

Jennifer


"John Bundy" wrote:

> I tried to recreate your form, but i'm not getting any errors. Where are you
> getting the error? The only thing that sticks out to me is you show this
> If ok Then
> found.Resize(, 6).Delete xlShiftUp
> LoadData
> Else
> but don't show the code for LoadData
> --
> -John
> Please rate when your question is answered to help us and others know what
> is helpful.
>
>
> "Jennifer" wrote:
>
> > I am getting an error
> > Object does not support this property or method
> >
> > Here is the code i am trying to use
> > Private Sub cmdDelete_Click()
> >
> > If lstData.ListIndex = -1 Then Exit Sub
> > ' Dim Index As String
> > Dim msg As String
> > Index = txtDataID.Text
> > msg = lstData.List(lstData.ListIndex, 1)
> > msg = msg & " " & lstData.List(lstData.ListIndex, 2)
> > msg = msg & " " & lstData.List(lstData.ListIndex, 3)
> > msg = msg & " " & lstData.List(lstData.ListIndex, 4)
> > If MsgBox(msg, vbYesNo + vbDefaultButton2, "DELETE #" & Index & " from "
> > & cboRation) = vbYes Then
> > RemoveItem Index
> > End If
> > End Sub
> > Private Sub RemoveItem(Index As String)
> > Dim found As Range
> > Dim ok As Boolean
> > With Worksheets("Rations")
> > For Each found In .Range(.Range("A2"), .Range("A2").End(xlDown))
> > If found = Index Then
> > ok = True
> > Exit For
> > End If
> > Next
> > End With
> > If ok Then
> > found.Resize(, 6).Delete xlShiftUp
> > LoadData
> > Else
> > MsgBox Index & " not found!"
> > End If
> > End Sub
> > --
> > Thank you,
> >
> > Jennifer

 
Reply With Quote
 
John Bundy
Guest
Posts: n/a
 
      30th Nov 2007
Sorry i really can't tell without seeing the sheet, someone here can i'm sure
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Jennifer" wrote:

> It is not showing where i am having the error just that i just put that part
> in so i assume it has to be in there.
>
> Here is the load data code that works in my update code and lstbox click code.
> Private Sub LoadData()
> With lstData
> .Clear
> Ration = cboRation.Value
> For Index = 2 To source.Rows.Count
> If Ration = source.Cells(Index, 2) Then
> .AddItem source.Cells(Index, 1) 'id
> ' .List(.ListCount - 1, 2) = source.Cells(index, eBoxes.Date1)
> .List(.ListCount - 1, 2) = source.Cells(Index, eBoxes.Ingredient)
> .List(.ListCount - 1, 3) = source.Cells(Index, eBoxes.Percent_of_ration)
> ' .List(.ListCount - 1, 5) = source.Cells(index, eBoxes.Ration_ID)
> .List(.ListCount - 1, 4) = source.Cells(Index, eBoxes.Pounds)
> End If
> Next
> End With
> End Sub
> --
> Thank you,
>
> Jennifer
>
>
> "John Bundy" wrote:
>
> > I tried to recreate your form, but i'm not getting any errors. Where are you
> > getting the error? The only thing that sticks out to me is you show this
> > If ok Then
> > found.Resize(, 6).Delete xlShiftUp
> > LoadData
> > Else
> > but don't show the code for LoadData
> > --
> > -John
> > Please rate when your question is answered to help us and others know what
> > is helpful.
> >
> >
> > "Jennifer" wrote:
> >
> > > I am getting an error
> > > Object does not support this property or method
> > >
> > > Here is the code i am trying to use
> > > Private Sub cmdDelete_Click()
> > >
> > > If lstData.ListIndex = -1 Then Exit Sub
> > > ' Dim Index As String
> > > Dim msg As String
> > > Index = txtDataID.Text
> > > msg = lstData.List(lstData.ListIndex, 1)
> > > msg = msg & " " & lstData.List(lstData.ListIndex, 2)
> > > msg = msg & " " & lstData.List(lstData.ListIndex, 3)
> > > msg = msg & " " & lstData.List(lstData.ListIndex, 4)
> > > If MsgBox(msg, vbYesNo + vbDefaultButton2, "DELETE #" & Index & " from "
> > > & cboRation) = vbYes Then
> > > RemoveItem Index
> > > End If
> > > End Sub
> > > Private Sub RemoveItem(Index As String)
> > > Dim found As Range
> > > Dim ok As Boolean
> > > With Worksheets("Rations")
> > > For Each found In .Range(.Range("A2"), .Range("A2").End(xlDown))
> > > If found = Index Then
> > > ok = True
> > > Exit For
> > > End If
> > > Next
> > > End With
> > > If ok Then
> > > found.Resize(, 6).Delete xlShiftUp
> > > LoadData
> > > Else
> > > MsgBox Index & " not found!"
> > > End If
> > > End Sub
> > > --
> > > Thank you,
> > >
> > > Jennifer

 
Reply With Quote
 
Jennifer
Guest
Posts: n/a
 
      30th Nov 2007
Thank you for your time i will keep at it.
--
Thank you,

Jennifer


"John Bundy" wrote:

> Sorry i really can't tell without seeing the sheet, someone here can i'm sure
> --
> -John
> Please rate when your question is answered to help us and others know what
> is helpful.
>
>
> "Jennifer" wrote:
>
> > It is not showing where i am having the error just that i just put that part
> > in so i assume it has to be in there.
> >
> > Here is the load data code that works in my update code and lstbox click code.
> > Private Sub LoadData()
> > With lstData
> > .Clear
> > Ration = cboRation.Value
> > For Index = 2 To source.Rows.Count
> > If Ration = source.Cells(Index, 2) Then
> > .AddItem source.Cells(Index, 1) 'id
> > ' .List(.ListCount - 1, 2) = source.Cells(index, eBoxes.Date1)
> > .List(.ListCount - 1, 2) = source.Cells(Index, eBoxes.Ingredient)
> > .List(.ListCount - 1, 3) = source.Cells(Index, eBoxes.Percent_of_ration)
> > ' .List(.ListCount - 1, 5) = source.Cells(index, eBoxes.Ration_ID)
> > .List(.ListCount - 1, 4) = source.Cells(Index, eBoxes.Pounds)
> > End If
> > Next
> > End With
> > End Sub
> > --
> > Thank you,
> >
> > Jennifer
> >
> >
> > "John Bundy" wrote:
> >
> > > I tried to recreate your form, but i'm not getting any errors. Where are you
> > > getting the error? The only thing that sticks out to me is you show this
> > > If ok Then
> > > found.Resize(, 6).Delete xlShiftUp
> > > LoadData
> > > Else
> > > but don't show the code for LoadData
> > > --
> > > -John
> > > Please rate when your question is answered to help us and others know what
> > > is helpful.
> > >
> > >
> > > "Jennifer" wrote:
> > >
> > > > I am getting an error
> > > > Object does not support this property or method
> > > >
> > > > Here is the code i am trying to use
> > > > Private Sub cmdDelete_Click()
> > > >
> > > > If lstData.ListIndex = -1 Then Exit Sub
> > > > ' Dim Index As String
> > > > Dim msg As String
> > > > Index = txtDataID.Text
> > > > msg = lstData.List(lstData.ListIndex, 1)
> > > > msg = msg & " " & lstData.List(lstData.ListIndex, 2)
> > > > msg = msg & " " & lstData.List(lstData.ListIndex, 3)
> > > > msg = msg & " " & lstData.List(lstData.ListIndex, 4)
> > > > If MsgBox(msg, vbYesNo + vbDefaultButton2, "DELETE #" & Index & " from "
> > > > & cboRation) = vbYes Then
> > > > RemoveItem Index
> > > > End If
> > > > End Sub
> > > > Private Sub RemoveItem(Index As String)
> > > > Dim found As Range
> > > > Dim ok As Boolean
> > > > With Worksheets("Rations")
> > > > For Each found In .Range(.Range("A2"), .Range("A2").End(xlDown))
> > > > If found = Index Then
> > > > ok = True
> > > > Exit For
> > > > End If
> > > > Next
> > > > End With
> > > > If ok Then
> > > > found.Resize(, 6).Delete xlShiftUp
> > > > LoadData
> > > > Else
> > > > MsgBox Index & " not found!"
> > > > End If
> > > > End Sub
> > > > --
> > > > Thank you,
> > > >
> > > > Jennifer

 
Reply With Quote
 
Jennifer
Guest
Posts: n/a
 
      30th Nov 2007
Ouch! I found it. i had tried to add this
Me.lblDate = WorksheetFunction.Today()

just before adding the delete button and didn't test it. Obviously it
doesn't work i just wanted a label to fill showing todays date. So small and
it just halts everything.
--
Thank you,

Jennifer


"Jennifer" wrote:

> I am getting an error
> Object does not support this property or method
>
> Here is the code i am trying to use
> Private Sub cmdDelete_Click()
>
> If lstData.ListIndex = -1 Then Exit Sub
> ' Dim Index As String
> Dim msg As String
> Index = txtDataID.Text
> msg = lstData.List(lstData.ListIndex, 1)
> msg = msg & " " & lstData.List(lstData.ListIndex, 2)
> msg = msg & " " & lstData.List(lstData.ListIndex, 3)
> msg = msg & " " & lstData.List(lstData.ListIndex, 4)
> If MsgBox(msg, vbYesNo + vbDefaultButton2, "DELETE #" & Index & " from "
> & cboRation) = vbYes Then
> RemoveItem Index
> End If
> End Sub
> Private Sub RemoveItem(Index As String)
> Dim found As Range
> Dim ok As Boolean
> With Worksheets("Rations")
> For Each found In .Range(.Range("A2"), .Range("A2").End(xlDown))
> If found = Index Then
> ok = True
> Exit For
> End If
> Next
> End With
> If ok Then
> found.Resize(, 6).Delete xlShiftUp
> LoadData
> Else
> MsgBox Index & " not found!"
> End If
> End Sub
> --
> Thank you,
>
> Jennifer

 
Reply With Quote
 
Jim Thomlinson
Guest
Posts: n/a
 
      30th Nov 2007
Try
Me.lblDate = Format(now(), "mm/dd/yyyy")

--
HTH...

Jim Thomlinson


"Jennifer" wrote:

> Ouch! I found it. i had tried to add this
> Me.lblDate = WorksheetFunction.Today()
>
> just before adding the delete button and didn't test it. Obviously it
> doesn't work i just wanted a label to fill showing todays date. So small and
> it just halts everything.
> --
> Thank you,
>
> Jennifer
>
>
> "Jennifer" wrote:
>
> > I am getting an error
> > Object does not support this property or method
> >
> > Here is the code i am trying to use
> > Private Sub cmdDelete_Click()
> >
> > If lstData.ListIndex = -1 Then Exit Sub
> > ' Dim Index As String
> > Dim msg As String
> > Index = txtDataID.Text
> > msg = lstData.List(lstData.ListIndex, 1)
> > msg = msg & " " & lstData.List(lstData.ListIndex, 2)
> > msg = msg & " " & lstData.List(lstData.ListIndex, 3)
> > msg = msg & " " & lstData.List(lstData.ListIndex, 4)
> > If MsgBox(msg, vbYesNo + vbDefaultButton2, "DELETE #" & Index & " from "
> > & cboRation) = vbYes Then
> > RemoveItem Index
> > End If
> > End Sub
> > Private Sub RemoveItem(Index As String)
> > Dim found As Range
> > Dim ok As Boolean
> > With Worksheets("Rations")
> > For Each found In .Range(.Range("A2"), .Range("A2").End(xlDown))
> > If found = Index Then
> > ok = True
> > Exit For
> > End If
> > Next
> > End With
> > If ok Then
> > found.Resize(, 6).Delete xlShiftUp
> > LoadData
> > Else
> > MsgBox Index & " not found!"
> > End If
> > End Sub
> > --
> > Thank you,
> >
> > Jennifer

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
entry error in a form Arvin Meyer [MVP] Microsoft Access Forms 4 17th Oct 2006 03:45 AM
Form Err.Raise error not trapped by entry procedure error handler jchauvin@panix.com Microsoft Excel Programming 1 8th Feb 2006 10:19 AM
Deleting a table entry from a form emanuel.levy@gmail.com Microsoft Access 1 2nd Nov 2005 05:49 PM
Error with ListBox and ArrayList when Deleting Last Entry John Veldthuis Microsoft VB .NET 5 23rd Oct 2005 04:18 AM
Populate Data Entry Form through listbox Brigitte P Microsoft Access Forms 11 15th Feb 2005 09:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:26 PM.