Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generating Numbers to Automatically Assign to Combo Box

Status
Not open for further replies.

Happy2

Programmer
Aug 10, 2001
64
US
Hi Steve and Everyone,

How is everyone doing? I still need some help with a problem.

I am having a problem with the tenth decimal numbers such as 0.1 and 0.10, 0.2 and 0.20, ...
For this reason, I can get up to number 9.9, then the next number is back to 2 again.
When I reach to 9.9, my DecPortion is 0.9 and DecIncrease is 0.9. Then the next number is 2 because the
DecPortion is 1 and DecIncrease is 1.1. Is there a function or a way to take care
of this problem. Please help. Thanks a lot. Below is the function:

Function NextID()

Dim vNextID As Double
Dim vIncrement As Double
Dim rs As New ADODB.Recordset
Dim db As New ADODB.Connection
Set rs = New ADODB.Recordset
rs.Open "Select * From tblNextID", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rs.MoveFirst
NextID = rs("NextID")
vNextID = rs("NextID") + 1

If vNextID >= 1000 Then
vNextID = 1 + (rs("DecPortion") + 0.1)
vIncrement = 0.1
rs("DecPortion") = rs("DecPortion") + 0.1
End If

rs("NextID") = vNextID
rs("DecIncrement") = rs("DecPortion") + vIncrement
rs.Update
rs.Close

End Function
 
what exactly are you trying to increment by?? 0.1 for each
next id?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top