-
Nov 1st, 2007, 02:19 PM
#1
Code not obeying simple mathematics
vb Code:
While Not rstScheduleDtl.EOF
If rstScheduleDtl!StartTime < Me!StartTime And rstScheduleDtl!EndTime > Me!EndTime Then
Call ftest(rstScheduleDtl!Status, rstScheduleDtl![Gala/FF])
Else
If Me!StartTime < rstScheduleDtl!EndTime < Me!EndTime Then
Call ftest(rstScheduleDtl!Status, rstScheduleDtl![Gala/FF])
Else
If Me!StartTime < rstScheduleDtl!StartTime < Me!EndTime Then
Call ftest(rstScheduleDtl!Status, rstScheduleDtl![Gala/FF])
End If
End If
End If
rstScheduleDtl.MoveNext
Wend
As you can see I am only using the > and < operands, and have not included anywhere an = or even a >=. However, as an example, when rstScheduleDtl!StartTime = Me!EndTime, which shouldn't fall into any of the categories above, the code is treating it as a conflict, meaning it thinks that case 3 is correct. Why is the code not honouring the < and > operands as they should be defined?
Just to point out, all of the above fields are using the same Medium Time Format (e.g. 05:34PM)
-
Nov 1st, 2007, 02:22 PM
#2
Re: Code not obeying simple mathematics
It is the Time < Time < Time in your IF statements:
For example. Try this, what do you think result is? Debug.Print 1 < 2 < 1
Change your IFs to a format like:
If (Time1 < Time2) And (Time2 < Time3)
-
Nov 1st, 2007, 02:24 PM
#3
Re: Code not obeying simple mathematics
The conditional seems wrong. You need to handle multiple conditions differently.
Code:
If (Me!StartTime < rstScheduleDtl!EndTime) AND (Me!StartTime < Me!EndTime) Then
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Nov 1st, 2007, 02:38 PM
#4
Re: Code not obeying simple mathematics
It worked! fantastic, thanks guys. Foolish of me to try and just slam out the code like an algebraic equation..
-
Nov 1st, 2007, 02:54 PM
#5
Re: Code not obeying simple mathematics
No prob. Actually in PHP you can do things like that logic.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
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
|