Unbound form, "dirty" textbox identify in code

  • Thread starter Thread starter Hindsey
  • Start date Start date
H

Hindsey

Hello, can anyone tell me how I would be able tell in code if a field on an
unbound form has been edited before I perform an action? Below is my
explanation:

I am going to be having 2 or 3 computers using this same form, and the data
is on a SQL Server Express. There's a list box, that when clicked on, the
information from a record populates the form. Since multiple people are
looking at, and may be changing the information on this record at the same
time, I don't want to use a bound form... So, whenever a field is updated,
SQL code runs updating the table. I also have an OnTimer even that checks the
table on the server to see if it has been updated. If it has been, then I
need to update the local form's data again.

The problem is that if the local form's data needs to be udpated, and I am
in the middle of typing in a field, that field gets erased. I would like to
be able to tell in the code that I am in the middle of updating that field,
and basically, to skip updating that field.

Any ideas?

Thanks
 
Hi,

Try something like this, substituting your field name for "Password"
and adjusting your code to use the value from the database rather than "New
Value":

Public m_boolPasswordChanged As Boolean

Private Sub Form_Open(Cancel As Integer)

m_boolPasswordChanged = False

End Sub

Private Sub Form_Timer()

If ActiveControl.Name <> [txtPassword].Name Or Not m_boolPasswordChanged
Then
If [txtPassword].Value <> "New Value" Then
[txtPassword].Value = "New Value"
End If
m_boolPasswordChanged = False
End If

End Sub

Private Sub txtPassword_Change()

m_boolPasswordChanged = True

End Sub

Hope that helps,

Clifford Bass
 
Back
Top