PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] type mismatch when searching date-VBForums
Results 1 to 33 of 33

Thread: [RESOLVED] type mismatch when searching date

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Resolved [RESOLVED] type mismatch when searching date

    hey

    im trying to search my listview by date

    i get error type mismatch why?
    this is the datepicker
    Code:
    Private Const mstrDateFormat As String = "dd-mm-yyyy"
    Private Sub DTPicker1_CloseUp()
        Dim lvi As ListItem
        Dim j As Long
        Dim d As Date
        d = Format$(DTPicker1.Value, mstrDateFormat)
        For j = FrmInvoices.LsVw.ListItems.Count To 1 Step -1
            Set lvi = FrmInvoices.LsVw.ListItems(j)
            If DateDiff("d", CDate(lvi.SubItems(2)), d) <> 0 Then
              FrmInvoices.LsVw.ListItems.Remove (j)
            End If
      
        Next
    End Sub
    this is the code of load
    Code:
    Private Sub Form_Load()
    Me.WindowState = 2
    ListRTL LsVw
    
    
       mLVClrHdr.HookToLV LsVw.hwnd, True
        mLVClrHdr.glHdrBkClr = &HD1B499
        mLVClrHdr.glHdrTextClr = vbWhite
        m_hookedLV = True
        
    Set RS = CN.Execute("SELECT * from Inventory ")
    While Not RS.EOF
    
    Set Itm = FrmInvoices.LsVw.ListItems.Add(, , RS!InvDate, , "invoice")
      Itm.bold = True
    Itm.SubItems(1) = RS!InvInvoice
    Itm.SubItems(2) = RS!InvItem
    Itm.SubItems(3) = RS!InvSupplier
    Itm.SubItems(4) = RS!InvCompany
    Itm.SubItems(5) = RS!invQuantity
    Itm.SubItems(6) = RS!InvRemarks
    RS.MoveNext
    Wend
    End Sub

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: type mismatch when searching date

    Once again which line has the error?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    Code:
      If DateDiff("d", CDate(lvi.SubItems(2)), d) <> 0 Then

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: type mismatch when searching date

    Is lvi.SubItems(2) a string value? CDate converts a string value.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    no subitems
    (2) is a text

    i think the date dosnt have a subitems
    Code:
    Set Itm = FrmInvoices.LsVw.ListItems.Add(, , RS!InvDate, , "invoice")
      Itm.bold = True

  6. #6
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: type mismatch when searching date

    What happens if you use

    vb Code:
    1. If DateDiff("d", CDate(lvi.SubItems(2).Text), d) <> 0 Then
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  7. #7

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    invaild qualefier

    the date is the first in the listview so no subitems i think
    i dont know :\
    Last edited by salsa31; Jul 8th, 2013 at 07:24 AM.

  8. #8
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: type mismatch when searching date

    Should that be?

    vb Code:
    1. If DateDiff("d", CDate(lvi.SubItems(j)), d) <> 0 Then
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  9. #9

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    type mismatch again

    Code:
    If DateDiff("d", CDate(lvi.SubItems(j)), d) <> 0 Then

  10. #10

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    the date is the first coulm in the listview
    i dont think it has a subitems according to this
    Code:
    Set Itm = FrmInvoices.LsVw.ListItems.Add(, , RS!InvDate, , "invoice")
      Itm.bold = True
    Itm.SubItems(1) = RS!InvInvoice
    Itm.SubItems(2) = RS!InvItem
    Itm.SubItems(3) = RS!InvSupplier
    Itm.SubItems(4) = RS!InvCompany
    Itm.SubItems(5) = RS!invQuantity
    Itm.SubItems(6) = RS!InvRemarks

  11. #11
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: type mismatch when searching date

    Salsa

    Let's first try to confirm where the date is "stored".
    Add these 3 lines to your code snipped, and put a break-point at b=b ...

    Code:
    Set Itm = FrmInvoices.LsVw.ListItems.Add(, , RS!InvDate,[/U] , "invoice")
      Itm.bold = True
    Itm.SubItems(1) = RS!InvInvoice
    Itm.SubItems(2) = RS!InvItem
    Itm.SubItems(3) = RS!InvSupplier
    Itm.SubItems(4) = RS!InvCompany
    Itm.SubItems(5) = RS!invQuantity
    Itm.SubItems(6) = RS!InvRemarks
    '
    v0 = Itm.SubItems(0)
    v1 = Itm.SubItems(1)
    b = b
    What value do you get for v0?
    What value do you get for v1?

    Spoo

  12. #12

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    external name not difined

    Code:
    [/U]

  13. #13

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    the subitems are stored in a diffrent table

    im just pulling some records from there to display in another form.

  14. #14

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    but when i added another subitems called InvExpired subitems (7) (date)it worked

    Code:
    If DateDiff("d", CDate(lvi.SubItems(7)), d) <> 0 Then
    Code:
    Itm.SubItems(7) = RS!InvExpired

  15. #15
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,034

    Re: type mismatch when searching date

    My guess would be that either you are usinf the wrong sub item or that you have a blank entry in it.

  16. #16

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    this is the code from the inventory table

    Code:
      Set Itm = LsVw.ListItems.Add(, , RS!InvDate, , "date")
      Itm.Tag = RS!InvID
    Itm.SubItems(1) = RS!InvItem
    Itm.SubItems(2) = RS!InvQuantity
    Itm.SubItems(3) = RS!InvBeforetax
    Itm.SubItems(4) = RS!InvInvoice
    Itm.SubItems(5) = RS!InvSupplier
    Itm.SubItems(6) = RS!InvEmail
    Itm.SubItems(7) = RS!InvPhone
    Itm.SubItems(8) = RS!InvBranch
    Itm.SubItems(9) = RS!InvFax
    Itm.SubItems(10) = RS!InvCompany
    Itm.SubItems(11) = RS!InvPaymentMethod
    Itm.SubItems(12) = RS!InvPayments
    Itm.SubItems(13) = RS!InvParts
    Itm.SubItems(14) = RS!InvExpire
    Itm.SubItems(15) = Format(RS!invTax / 100, ".##%")
    Itm.SubItems(16) = RS!InvAftertax
    Itm.SubItems(17) = RS!InvForCust
    Itm.SubItems(18) = RS!InvRemarks

  17. #17
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,034

    Re: type mismatch when searching date

    Itm.SubItems(2) = RS!InvQuantity
    Well if this is what is going into the list then clearly subitem 2 is not a date, in fact it doesn't look like any of those are a date other than maybe subitem 14

  18. #18

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    so if date is in the first column with no subitems then how do you search by date?

  19. #19
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: type mismatch when searching date

    Salsa

    You keep talking about the first column... first column of what?
    Could you provide a screen-shot?

    Spoo

  20. #20

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    look spoo

    Code:
    Set Itm = FrmInvoices.LsVw.ListItems.Add(, , RS!InvDate, , "invoice")
      Itm.bold = True
    Itm.SubItems(1) = RS!InvInvoice
    Itm.SubItems(2) = RS!InvItem
    Itm.SubItems(3) = RS!InvSupplier
    Itm.SubItems(4) = RS!InvCompany
    Itm.SubItems(5) = RS!invQuantity
    Itm.SubItems(6) = RS!InvRemarks
    you see the InvDate?
    when i add something to my database the first thing it adds is the InvDate (Set Itm = FrmInvoices.LsVw.ListItems.Add(, , [RS!InvDate, "invoice")
    this is what i first see in the listview the date
    and if the date is first how can itm.subitems(1) = RS!Invoice be subitems 1?
    so whats the subitem for InvDate?

  21. #21
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: type mismatch when searching date

    Salsa

    Sorry for mis-communication.
    What you just did is what I would call a "code snippet"

    By a "screen-shot", I meant an image of the control on your form.
    Do you know how to grab and attach an image to your reply?

    Spoo

  22. #22

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    sure
    tell me image of what you want to see?
    screen shot of what?

  23. #23

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date


  24. #24
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: type mismatch when searching date

    Salsa

    Sorry, but for some reason I can't see anything.

    Perhaps you could try again, using the technique you used earlier
    in post #13 of this thread ..

    http://www.vbforums.com/showthread.p...y-value-in-mdi

    Spoo

  25. #25

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date


  26. #26
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: type mismatch when searching date

    Salsa

    OK, I can definitely see that ,,

    However, I can't tell where your ListView control is.
    In other words, regarding my post #19, "the first column of what"?
    I'm hoping to see a date in the first column of it.

    Spoo

  27. #27

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    look in the pic on the right in the listview
    8/7/2012 thats the date

  28. #28
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: type mismatch when searching date

    Salsa

    OK, I see a date 8/7/2013 at the right, in row 1

    I must confess to not having used a ListView control before, but, could
    it be that instead of it being the "first" column, it is rather the "last" column.

    I know that a MSFlexGrid control, for example, begins with the left column being Col = 0.

    Perhaps the same applies to a ListView. I can see 8 columns in your screenshot.
    If they are all part of the same ListView, then perhaps you need to reference Col = 7.
    However, I don't see a Col Property, so, I really don't have a clue.

    Spoo

  29. #29

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    np spoo

  30. #30
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,034

    Re: type mismatch when searching date

    Ok sounds like you need to be using the Item.text rather than any of the sub items as what you are wanting to search for is not in the subitems but is the main item text

  31. #31

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    Quote Originally Posted by DataMiser View Post
    Ok sounds like you need to be using the Item.text rather than any of the sub items as what you are wanting to search for is not in the subitems but is the main item text
    and how do i do that?

  32. #32
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,034

    Re: type mismatch when searching date

    Rather than
    Code:
    lvi.SubItems(2)
    You would use
    Code:
    lvi.Text
    Been a while since I used a list view in VB6 but I think that is correct.

  33. #33

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,093

    Re: type mismatch when searching date

    tnk you datamiser its working now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width