The switchboard executes a macro which runs the function RunFixSONO.The function RunFixSONO calls the procedure FixSONO, and everything works properly except that the procedure is called 3 times. I placed the MsgBox statements in the procedure code to tell me when I am entering and leaving the procedure and I see it happen 3 times. I am incredulous … can someone please tell me what is happening here? Why is the procedure running exactly 3 times, every time, when I only call it once?
Function RunFixSONO()
FixSONO
End Function
Sub FixSONO()
Dim db As Database
Dim rsDaily As Recordset
Dim vCountProcessed As Integer
Dim vmsg As String
Dim vErrorFlag As Integer
Dim vSONO As String
vmsg = “entering Procedure”
MsgBox (vmsg)
vCountProcessed = 0
vErrorFlag = 0
Set db = CurrentDb
Set rsDaily = db.OpenRecordset(“DAILY”, dbOpenDynaset)
Do While rsDaily.EOF = False And vErrorFlag = 0
With rsDaily
‘If SONO length = 8
If Len(rsDaily!SONO) = 8 Then
rsDaily.Edit
rsDaily!SONO = Mid(rsDaily!SONO, 4, 7)
.Update
vCountProcessed = vCountProcessed + 1
Else
vErrorFlag = 1
End If
.MoveNext
End With
Loop
If vErrorFlag = 1 Then
vmsg = “Incorrect SONO Length encountered; Notify Management”
MsgBox (vmsg)
vmsg = vCountProcessed & ” SONO records were processed before the error”
MsgBox (vmsg)
Else
vmsg = vCountProcessed & ” SONO records were processed”
MsgBox (vmsg)
End If
DoCmd.OpenQuery “qryAppend SBT data”
‘Close open objects
rsDaily.Close
db.Close
vmsg = “leaving Procedure”
MsgBox (vmsg)
End Sub
Sorry about losing the indents. I don’t know how to keep them when I paste the code in.
Thank you in advance to anyone who can take a look at this and give me a clue.