> > Dim wsCheck, wsPymt, wsExp, wsDiff As Double
> This doesn't do what you think. The first three variables take the
default
> datatype, which is variant. Unless you want variant, dim each variable
> separately.
> > wsCheck = Text1(10)
> Since wsCheck is variant, this assignment coerces the variant to a string
> and assigns a string to it.
> > wsExp = rs5.Fields("Expected_Amt")
> This assignment coerces the variant to a numeric datatype to hold the
value.
> > If wsCheck >= wsExp Then
> wsCheck is a variant containing a string and wsExp is a variant containing
a
> numeric. I don't know the rules for comparing different datatypes, so I
> don't know when this would be true or false.
> Your code is going to be full of hard to understand problems like this
> unless you adopt some coding conventions. Here are my own rules:
> 1. Always explicitly declare variables with the correct datatype for the
> data.
> 2. Use hungarian notation to make it obvious what datatype a variable is.
> 3. Never allow VB to coerce a value, always convert datatypes explicitly.
> This would make your code look something like this (using my own
hungarian):
> Dim lc_Check As Currency
> Dim lc_ExpectedAmount As Currency
> lc_Check = CCur(text1(10))
> Do Until rs5.EOF
> lc_ExpectedAmount = CCur(rs5.Fields("Expected_Amt"))
> If lc_Check >= lc_ExpectedAmount Then
> I can see lots of other problems you are going to encounter. What if
> text1(10) is not numeric? What datatype is text1 anyway? What if
> Expected_Amt is null? For production applications, the goal is to make
them
> "robust", or cabable of handling their own errors and running with few
> exceptions. You need to evaluate your design with the goal of making it
> more robust.
> There are some other issues with your code. In my opinion, "rs5" is a
> horrible name for a variable, and it makes me think that you probably have
> four other recordsets similiarly named. Try to break your code into
> subroutines and pass in the variables they need. Having five recordsets
in
> a module and referring to them all over the place is going to make your
> program a nightmare to work on.
> One last thing: if these five recordsets all have active connections, I
hope
> you don't expect to open many more connections to the same database.
> Good luck with your development effort.