A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Lock/unlock form button



 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old February 11th, 2010, 05:37 AM posted to microsoft.public.access.forms
Rlong
external usenet poster
 
Posts: 1
Default Lock/unlock form button

I've successfully created a button that locks/unlocks all the fields in a
form. In addition, it keeps all fields unlocked during initial record
creation, but requires the user to use the button whenever any fields in the
form are edited. This was accomplished by following the instructions and code
(see pasted at bottom of this post) at the following web address under
"Double-Action Command Button" posted on 3/28/08:

http://www.msaccesstips.com/labels/m...%20forms.shtml

This does almost exactly what I want, but I'd like to have one of the fields
on the form (a combo box field that looks up and returns a given record in
the rest of the form) not lock each time. That is, I'd like it to remain
unlocked and available for repeat use without having to click the lock/unlock
button each time. Is this possible?

Thanks


The code portion of the application is as follows:

Private Sub Form_Current()
If Me.NewRecord Then
With Me
.cmdEdit.Caption = "Edit"
.cmdEdit.ForeColor = 0
.cmdEdit.FontBold = False
.AllowEdits = True
.cmdEdit.Enabled = False
End With
Else
With Me
.AllowEdits = False
.cmdEdit.Caption = "Edit"
.cmdEdit.ForeColor = 0
.cmdEdit.FontBold = False
.cmdEdit.Enabled = True
End With
End If

End Sub


AND


Private Sub cmdEdit_Click()
Dim cap As String
cap = Me.cmdEdit.Caption
Select Case cap
Case "Edit"
With Me
.AllowEdits = True
.cmdEdit.Caption = "Lock"
.cmdEdit.ForeColor = 128
.cmdEdit.FontBold = True
.Refresh
End With
Case "Lock"
With Me
.AllowEdits = False
.cmdEdit.Caption = "Edit"
.cmdEdit.ForeColor = 0
.cmdEdit.FontBold = False
.Refresh
End With
End Select
End Sub

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


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