Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Set Boolean Variable for Changing Any Control on Userform

I want to notify the user if they make any changes to the userform when they
click the OK button on the userform. The userform has about 90 controls on
it. Do I have to set the variable bolFormChanged = True under a Change Event
for each control or is there a shortcut to doing this?

Thanks in Advance!

For Example,

Private Sub btnOK_Click()

If bolFormChanged = True Then
' notify user with msgbox
Else
' Do This
End If

End Sub
--
Cheers,
Ryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Set Boolean Variable for Changing Any Control on Userform


Use the tag property to store the values on click OK and check that everytime
when you click OK . Something as below

Private Sub btnOK_Click()

'Click OK
Dim blnChange As Boolean
For Each ctl In UserForm1.Controls
If ctl.Tag < ctl.Text Then blnChange = True
ctl.Tag = ctl.Text
Next

If blnChange = True Then
'Data changed
'do something
End If


End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Ryan H" wrote:

I want to notify the user if they make any changes to the userform when they
click the OK button on the userform. The userform has about 90 controls on
it. Do I have to set the variable bolFormChanged = True under a Change Event
for each control or is there a shortcut to doing this?

Thanks in Advance!

For Example,

Private Sub btnOK_Click()

If bolFormChanged = True Then
' notify user with msgbox
Else
' Do This
End If

End Sub
--
Cheers,
Ryan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Set Boolean Variable for Changing Any Control on Userform


Hi Ryan

Code slightly modified to filter controls...by type..the below will look for
changes in Textbox controls and combox controls. Adjust to suit...

Private Sub btnOK_Click()

'Click OK
Dim blnChange As Boolean
For Each ctl In UserForm1.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
If ctl.Tag < ctl.Text Then blnChange = True
ctl.Tag = ctl.Text
End If
Next

If blnChange = True Then
'Data changed do something
End If


End Sub



If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Use the tag property to store the values on click OK and check that everytime
when you click OK . Something as below

Private Sub btnOK_Click()

'Click OK
Dim blnChange As Boolean
For Each ctl In UserForm1.Controls
If ctl.Tag < ctl.Text Then blnChange = True
ctl.Tag = ctl.Text
Next

If blnChange = True Then
'Data changed
'do something
End If


End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Ryan H" wrote:

I want to notify the user if they make any changes to the userform when they
click the OK button on the userform. The userform has about 90 controls on
it. Do I have to set the variable bolFormChanged = True under a Change Event
for each control or is there a shortcut to doing this?

Thanks in Advance!

For Example,

Private Sub btnOK_Click()

If bolFormChanged = True Then
' notify user with msgbox
Else
' Do This
End If

End Sub
--
Cheers,
Ryan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Set Boolean Variable for Changing Any Control on Userform


Thanks that got me pointed in the right direction!
--
Cheers,
Ryan


"Jacob Skaria" wrote:

Hi Ryan

Code slightly modified to filter controls...by type..the below will look for
changes in Textbox controls and combox controls. Adjust to suit...

Private Sub btnOK_Click()

'Click OK
Dim blnChange As Boolean
For Each ctl In UserForm1.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
If ctl.Tag < ctl.Text Then blnChange = True
ctl.Tag = ctl.Text
End If
Next

If blnChange = True Then
'Data changed do something
End If


End Sub



If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Use the tag property to store the values on click OK and check that everytime
when you click OK . Something as below

Private Sub btnOK_Click()

'Click OK
Dim blnChange As Boolean
For Each ctl In UserForm1.Controls
If ctl.Tag < ctl.Text Then blnChange = True
ctl.Tag = ctl.Text
Next

If blnChange = True Then
'Data changed
'do something
End If


End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Ryan H" wrote:

I want to notify the user if they make any changes to the userform when they
click the OK button on the userform. The userform has about 90 controls on
it. Do I have to set the variable bolFormChanged = True under a Change Event
for each control or is there a shortcut to doing this?

Thanks in Advance!

For Example,

Private Sub btnOK_Click()

If bolFormChanged = True Then
' notify user with msgbox
Else
' Do This
End If

End Sub
--
Cheers,
Ryan

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm Control references as variable donwb Excel Programming 2 August 23rd 08 05:59 PM
Passing variable values to userform control KJ-clueless Excel Discussion (Misc queries) 2 November 27th 07 10:51 PM
changing selected label on userform w/ a variable mike k Excel Programming 1 February 19th 04 01:48 AM
UserForm not passing Boolean variable Chip Pearson Excel Programming 2 July 19th 03 06:06 PM
Assigning the name of a userform/control to a changing string Brad Patterson Excel Programming 2 July 16th 03 11:00 PM


All times are GMT +1. The time now is 09:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"