Declare a public variable as Boolean
At the start of your progran check if the flag is true, if it is then quit
If Not then Set the Variable to true
When the program ends set your variable to False
This is an extract from a userform application:
Public ChangeFlagAs Boolean
Private Sub TelNo()
If ChangeFlag = True Then Exit Sub
ChangeFlag = True
temp = TextBox5.Text
NO = Replace(Me.Controls("Textbox" & T).Text, " ", "")
If NO = "" Or Not IsNumeric(NO) Then GoTo 200
Count = 1: Length = Len(NO)
10 temp = Mid(NO, Count, 1)
If Asc(temp) > 47 And Asc(temp) < 58 Then GoTo 20
NO = Left(NO, Count - 1): If Count < Length Then NO = NO & Right(Text, Length - Count)
Length = Length - 1: Count = Count - 1
20 Count = Count + 1: If Count <= Length Then GoTo 10
If Len(NO) > 4 Then NO = Left(NO, 4) & " " & Right(NO, Len(NO) - 4)
If Len(NO) > 8 Then NO = Left(NO, 8) & " " & Right(NO, Len(NO) - 8)
If Len(NO) > 13 Then NO = Left(NO, 13)
Me.Controls("Textbox" & T).Text = NO
200 ' exit
ChangeFlag = False
End Sub
Bookmarks