On Lost Focus only works once???

J-F

Registered User.
Local time
Today, 06:30
Joined
Nov 14, 2001
Messages
41
I have a text box on a form with an 'On Lost Focus' procedure. I need this to work every time it loses focus but only seems to work on the first occassion of it losing focus.

Is this correct?
If so, how can I get it to work everytime it loses focus?
 
Private Function UpdateCheckSum()
Dim recClone As Recordset
Dim CommaPos1 As Integer
Dim CommaPos2 As Integer
Dim AddNumbers As Integer

Set recClone = Me.RecordsetClone()
recClone.Bookmark = Me.Bookmark
strPosts = "," & recClone("comms1d") & ","
strPosts = strPosts & recClone("comms1n") & ","
recClone.Close

AddNumbers = 0
CommaPos1 = 0
CommaPos2 = 1
x = 0

While CommaPos2 <> 0
x = x + 1
CommaPos1 = InStr(CommaPos2, strPosts, ",")
CommaPos2 = InStr((CommaPos1 + 1), strPosts, ",")
If ((CommaPos2 - CommaPos1) <> 1) And (CommaPos2 <> 0) Then
AddNumbers = AddNumbers + CInt(Mid(strPosts, (CommaPos1 + 1), ((CommaPos2 - CommaPos1) - 1)))
End If
Wend
CheckSum = AddNumbers

End Function

Private Sub comms1d_LostFocus()
UpdateCheckSum
End Sub

Private Sub comms1n_LostFocus()
UpdateCheckSum
End Sub


Numbers are entered in the comms1d and comms1n textboxes seperated by commas. I need to do a checksum of all the numbers entered in both boxes and display the result in CheckSum.
 

Users who are viewing this thread

Back
Top Bottom