|
-
May 15th, 2006, 03:35 AM
#1
Thread Starter
Member
type mismatch error
Hi guys. I' am getting a problem concerning date.
VB Code:
dateborrowed = pbRst!borrowdate 'where dateborrowed is STRING and 'borrowdate is of type medium date in the mdb
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
-
May 15th, 2006, 03:50 AM
#2
-
May 15th, 2006, 06:58 AM
#3
Thread Starter
Member
Re: type mismatch error
Thanks nagasrikanth my problem is solved but i'am getting another error
VB Code:
Set pbRst = RstSel("select * from borrow where serialno = '" & pvserial & "'")
If Not pbRst.EOF And Not pbRst.BOF Then
If pbRst!expecteddate > pbRst!datereturn Then
MsgBox "This film has been overdue! PENALTY AWARDED!", vbOKOnly + vbExclamation
lateness = pbRst!datereturned - pbRst!expecteddate
lcsql = "update borrow set lateness = '" & lateness & "',Status = 'RETURNED' where serialno = '" & pvserial & "'"
SqlEXE (lcsql)
Set rst = RstSel("SELECT * FROM CATALOGUE INNER JOIN MEDIA ON CATALOGUE.CatId=MEDIA.CatId WHERE media.serialno = '" & pvserial & "'")
If rst!mediatype = "VCD" Then
lcsql = "insert into penalty values '" & pvserial & "','" & cboMembershipId.Text & "','" & rst!VCPnRATE & "','UNPAID' ,'" & txtDateReturned.Text & "'"
SqlEXE (lcsql)
ElseIf rst!mediatype = "DVD" Then
lcsql = "insert into penalty values '" & pvserial & "','" & cboMembershipId.Text & "','" & rst!DVPnRATE & "','UNPAID' ,'" & txtDateReturned.Text & "'"
SqlEXE (lcsql)
Else
End If
Else
End If
End If
when this line:
VB Code:
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...
-
May 15th, 2006, 07:57 AM
#4
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.
-
May 15th, 2006, 09:46 AM
#5
Thread Starter
Member
Re: type mismatch error
ok thanks.....lol
-
May 15th, 2006, 09:54 AM
#6
Thread Starter
Member
Re: type mismatch error
man i'am getting another problem
VB Code:
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
-
May 15th, 2006, 09:59 AM
#7
Re: type mismatch error
You need to use the DateDiff function, eg:
VB Code:
lateness = datediff("d",pbRst!datereturned,pbRst!expecteddate)
(if the value is negative, just swap the fields around - or use the Abs function).
-
May 15th, 2006, 10:40 AM
#8
Thread Starter
Member
-
May 15th, 2006, 11:32 PM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|