Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Access Newsgroups
Access Conversion
sql problem
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="John Nurick, post: 1438283"] Your code is much less difficult to read if you indent it properly. Other comments below refer to the lines marked with <<<< Public Function isPocetakBroja(ByVal IngFactor As String) As Long Dim pocetakBroja, krajBroja, drugipocetakBroja As Long '<<<<1 'assumes that the FactorSum value is a number, and is a Long Integer. Select Case Left(IngFactor, 8) Case Is = "dov. zal" pocetakBroja = InStr(10, IngFactor, "dana (", vbTextCompare) + 6 drugipocetakBroja = InStr(10, IngFactor, _ "dana (>", vbTextCompare) + 7 If drugipocetakBroja > pocetakBroja Then isPocetakBroja = Right(Left(IngFactor, krajBroja), _ drugipocetakBroja) '<<<<2 Else isPocetakBroja = Right(Left(IngFactor, krajBroja), pocetakBroja) End If Case Is = "dovoljno" pocetakBroja = InStr(5, IngFactor, "no (", vbTextCompare) + 4 drugipocetakBroja = InStr(5, IngFactor, _ "no (>", vbTextCompare) + 5 If drugipocetakBroja > pocetakBroja Then isPocetakBroja = Right(Left(IngFactor, krajBroja), _ drugipocetakBroja) Else isPocetakBroja = Right(Left(IngFactor, krajBroja), pocetakBroja) '...here is type mismatch End If Case Is = "sti¾e da" isPocetakBroja = 5 Case Else 'use this if you need a default for records outside of all isPocetakBroja = 999 End Select End Function 1) This line declares pocetakBroja and krajBroja as Variants and only drugipocetakBroja as a Long, which is probably not what you intend. 2) In this line and several others, the assignment to isPocetakBroja requires a Long but you are are using Right(), which is a string-handling function. So the first thing to do is exclude the possibility that the "Right(Left())" expression is returning a string that does not represent a number. When the code breaks, click Debug, open the Immediate pane, type ? Right(Left(IngFactor, krajBroja), pocetakBroja) and hit Enter. If the result is not a valid number, either your code isn't quite right or your data isn't quite as you expect. [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Access Newsgroups
Access Conversion
sql problem
Top