Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Lock userform for editing

Is there a way to SHOW a userform as Read Only?
When the userform is initialized, its textboxes and checkboxes are already
populated with data from a worksheet. I don't want the users to change or
edit this data. I only want them to view it. Is it possible to lock the form
for editing?
excel 2003
tendresse
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Lock userform for editing

Hi

You have to set the Enabled Property to False.

With the code below only CommandButton1 will be active on the form.

Private Sub UserForm_Initialize()
For Each fi In Me.Controls
If fi.Name < "CommandButton1" Then
fi.Enabled = False
End If
Next
End Sub

Hopes this helps.

---
Per

"Tendresse" skrev i meddelelsen
...
Is there a way to SHOW a userform as Read Only?
When the userform is initialized, its textboxes and checkboxes are already
populated with data from a worksheet. I don't want the users to change or
edit this data. I only want them to view it. Is it possible to lock the
form
for editing?
excel 2003
tendresse


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Lock userform for editing

As Per suggests the normal way is to set the enabled property to false. This
leaves them greyed, which conforms to conventions to indicate user cannot
change the control. If you do not want the greyed effect you can immediately
exit controls, eg

Put at least two Commandbuttons on a form, a Textbox and a Checkbox. Run the
form and try and change the textbox & checkbox

'userform code
Private mbExitFocus As Boolean

Private Sub CheckBox1_Enter()
If mbExitFocus Then Me.CommandButton1.SetFocus
End Sub

Private Sub TextBox1_Enter()
If mbExitFocus Then Me.CommandButton1.SetFocus
End Sub

Private Sub UserForm_Initialize()
mbExitFocus = True
CommandButton1.Left = -100 ' hide it
End Sub

Regards,
Peter T

"Tendresse" wrote in message
...
Is there a way to SHOW a userform as Read Only?
When the userform is initialized, its textboxes and checkboxes are already
populated with data from a worksheet. I don't want the users to change or
edit this data. I only want them to view it. Is it possible to lock the
form
for editing?
excel 2003
tendresse



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
copy cells but lock editing Lise Excel Discussion (Misc queries) 5 April 15th 10 12:39 PM
lock for editing des-sa[_2_] Excel Discussion (Misc queries) 3 January 15th 09 09:01 PM
lock for editing des-sa[_2_] Excel Discussion (Misc queries) 0 January 15th 09 06:01 PM
How do I lock some fields but allow editing for others in excel S.Sharif Excel Discussion (Misc queries) 1 December 13th 05 02:58 AM
Lock Header Rows from Editing HotRod Excel Programming 7 November 11th 05 04:29 PM


All times are GMT +1. The time now is 05:12 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"