Many times when I want to change a control value but not have it execute the code, I'll set its tag to something and check for that value when the event fires. Something like this:
Code:Private Sub Text2_Change() If Text2.Tag = "ignore" Then Exit Sub ' < added IF statement On Error GoTo error databasepetatable 'connect record table peta menggunakan modul syskod tablesys.Close tablesys.Open "Select * from peta where Kod = '" & Text2.Text & "'", consys, adOpenDynamic, adLockOptimistic If Not tablesys.BOF And Not tablesys.EOF Then Text10.Text = tablesys.Fields("Peta").Value Else MsgBox ("Tiada Rekod dijumpai") Text2.Tag = "ignore" ' < added Tag value Text2.Text = "" Text2.Tag = vbNullString ' < added Tag value Text10.Text = "" End If error: End Sub




Reply With Quote