Results 1 to 9 of 9

Thread: type mismatch error

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    58

    type mismatch error

    Hi guys. I' am getting a problem concerning date.

    VB Code:
    1. dateborrowed = pbRst!borrowdate 'where dateborrowed is STRING and 'borrowdate is of type medium date in the mdb
    2.                
    3. expecteddate = dateborrowed + rst!VCDayslimit   'Where expecteddate is 'STRING VCDayslimit is of type number in the mdb
    When executed i get a type mismatch error

    How can i fix this please
    btw iam on vb6,database:ACCESS and connection adodb

    thank u

  2. #2
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: type mismatch error

    dateborrowed 'n' expecteddate should be of DATE dataType...
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

  3. #3

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    58

    Re: type mismatch error

    Thanks nagasrikanth my problem is solved but i'am getting another error

    VB Code:
    1. Set pbRst = RstSel("select * from borrow where serialno = '" & pvserial & "'")
    2.     If Not pbRst.EOF And Not pbRst.BOF Then
    3.         If pbRst!expecteddate > pbRst!datereturn Then
    4.             MsgBox "This film has been overdue! PENALTY AWARDED!", vbOKOnly + vbExclamation
    5.             lateness = pbRst!datereturned - pbRst!expecteddate
    6.             lcsql = "update borrow set lateness = '" & lateness & "',Status = 'RETURNED'  where serialno = '" & pvserial & "'"
    7.             SqlEXE (lcsql)
    8.             Set rst = RstSel("SELECT * FROM CATALOGUE INNER JOIN MEDIA ON CATALOGUE.CatId=MEDIA.CatId WHERE media.serialno = '" & pvserial & "'")
    9.             If rst!mediatype = "VCD" Then
    10.                 lcsql = "insert into penalty values '" & pvserial & "','" & cboMembershipId.Text & "','" & rst!VCPnRATE & "','UNPAID' ,'" & txtDateReturned.Text & "'"
    11.                 SqlEXE (lcsql)
    12.             ElseIf rst!mediatype = "DVD" Then
    13.                 lcsql = "insert into penalty values '" & pvserial & "','" & cboMembershipId.Text & "','" & rst!DVPnRATE & "','UNPAID' ,'" & txtDateReturned.Text & "'"
    14.                 SqlEXE (lcsql)
    15.             Else
    16.             End If
    17.                        
    18.         Else
    19.         End If
    20.     End If

    when this line:
    VB Code:
    1. If pbRst!expecteddate > pbRst!datereturn Then
    is executed pbRst!expecteddate has value:5/15/2006 and pbRst!datereturn has value 5/17/2006

    but the problem is that it bybasses the statement just after the condition and goes directly to else endif

    whats wrong with this guys?


    Thanks for your coorperation...

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: type mismatch error

    It's the same as: "If '5/15/2006' > '5/17/2006' Then".. as the 15th is earlier than the 17th, the If condition isn't true.

  5. #5

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    58

    Re: type mismatch error

    ok thanks.....lol

  6. #6

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    58

    Re: type mismatch error

    man i'am getting another problem

    VB Code:
    1. lateness = pbRst!datereturned - pbRst!expecteddate
    pbRst!datereturned = 5/30/2006 and pbRst!expecteddate =5/17/2006

    when the above is exeuted lateness becomes 1/12/1900

    how do i do o get the difference in number of days ie 13

    thanks for your replies guys coz u r helping me a lot

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: type mismatch error

    You need to use the DateDiff function, eg:
    VB Code:
    1. lateness = datediff("d",pbRst!datereturned,pbRst!expecteddate)
    (if the value is negative, just swap the fields around - or use the Abs function).

  8. #8

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    58

    Re: type mismatch error

    thanks man

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: type mismatch error

    And there's no reason to have that Else in there just before the End. Execution will go to the End if the condition is false. You're just creating a mess of unused (but executed) code in the exe. ("If condition = false then goto" type instructions, and the labels for them to go to.)
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

Posting Permissions

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



Click Here to Expand Forum to Full Width