Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chech for changes in a form

Status
Not open for further replies.

djburnheim

Technical User
Jan 22, 2003
71
0
0
AU
I've got a simple form that displays values from cells in an excel workbook and I'm trying to find a simple way of checking to see if a user makes any changes in the form so I can update the workbook if needed. I can think of 2 ways of doing it but both seem long winded any other suggestions?

Many thanks
Dave
______________
Option 1
Use if then statement to check that form value = cell value for each control in the form

Private Sub cmdClose_Click()

Dim Userchange as Boolean

If UserForm.TextBox1 <> Sheets(&quot;Sheet1&quot;).Range(&quot;A1&quot;) Then
UserChange = True
End If

'Repeat for each control on form

If UserChange = True Then
'msgbox prompting user to save changes
End If
End Sub
_______________
Option 2
Have a change event for each control

Dim Userchange as boolean

Private Sub TextBox1_Change()
Userchange = True
End Sub

Private Sub cmdClose_Click
If UserChange = True Then
'msgbox prompting user to save changes
End if
End Sub
______________
 
Use the ControlSource property of yours TextBoxes to link them with the cells. You can then check the Saved property of your workbook.

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top