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  

Freeze fields with a command button click



 
 
Thread Tools Display Modes
  #1  
Old May 25th, 2010, 05:34 PM posted to microsoft.public.access.forms
PJ
external usenet poster
 
Posts: 265
Default Freeze fields with a command button click

How would I lock multiple fields so a user can not change based on a click of
a button. There is a date field so once it hit month end I would like to
freeze a user from changing the record. How is that possible?


Thanks
  #2  
Old May 25th, 2010, 05:52 PM posted to microsoft.public.access.forms
PieterLinden via AccessMonster.com
external usenet poster
 
Posts: 307
Default Freeze fields with a command button click

PJ wrote:
How would I lock multiple fields so a user can not change based on a click of
a button. There is a date field so once it hit month end I would like to
freeze a user from changing the record. How is that possible?

Thanks


Note that you cannot lock anything at table level. If the user has access to
update/delete queries that modify data, this won't work.

Sub cmdLockControls_Click()
With Me.Controls("ControlToLock")
.Enabled = False
.Locked = True
End with
End sub

You would have to have a boolean field in your table containing the status of
the record. Something like IsLocked... then in the OnCurrent event of the
form,

With Me.Controls("ControlToLock")
.Enabled = Not me!IsLocked
.Locked = Me!IsLocked
End with

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201005/1

  #3  
Old May 25th, 2010, 06:09 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Freeze fields with a command button click

PJ -

Use the On Current event so this occurs each time a new record is displayed
(use your fieldnames):

If Me.DateField DateSerial(Year(Date()),Month(Date(),1) Then
Me.Field1.Locked = True
Me.Field2.Locked = True
...
Me.Fieldn.Locked = True
Else
Me.Field1.Locked = False
Me.Field2.Locked = False
...
Me.Fieldn.Locked = False
End If

--
Daryl S


"PJ" wrote:

How would I lock multiple fields so a user can not change based on a click of
a button. There is a date field so once it hit month end I would like to
freeze a user from changing the record. How is that possible?


Thanks

  #4  
Old May 25th, 2010, 07:21 PM posted to microsoft.public.access.forms
PJ
external usenet poster
 
Posts: 265
Default Freeze fields with a command button click


Thanks again Daryl. I guess I am not getting this. Would this go on the
form's current event. I wanted a button that I would click on that at any
given time I can click on and it would lock 6 fields and you could only read
them. Where would they below code go?

Thanks!!
"Daryl S" wrote:

PJ -

Use the On Current event so this occurs each time a new record is displayed
(use your fieldnames):

If Me.DateField DateSerial(Year(Date()),Month(Date(),1) Then
Me.Field1.Locked = True
Me.Field2.Locked = True
...
Me.Fieldn.Locked = True
Else
Me.Field1.Locked = False
Me.Field2.Locked = False
...
Me.Fieldn.Locked = False
End If

--
Daryl S


"PJ" wrote:

How would I lock multiple fields so a user can not change based on a click of
a button. There is a date field so once it hit month end I would like to
freeze a user from changing the record. How is that possible?


Thanks

  #5  
Old May 25th, 2010, 08:17 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Freeze fields with a command button click

One approach would be simply to call the form's Current event in the
button's Click event:

Private Sub MyButton_Click()

Call Form_Current()

End Sub

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"PJ" wrote in message
...

Thanks again Daryl. I guess I am not getting this. Would this go on the
form's current event. I wanted a button that I would click on that at any
given time I can click on and it would lock 6 fields and you could only
read
them. Where would they below code go?

Thanks!!
"Daryl S" wrote:

PJ -

Use the On Current event so this occurs each time a new record is
displayed
(use your fieldnames):

If Me.DateField DateSerial(Year(Date()),Month(Date(),1) Then
Me.Field1.Locked = True
Me.Field2.Locked = True
...
Me.Fieldn.Locked = True
Else
Me.Field1.Locked = False
Me.Field2.Locked = False
...
Me.Fieldn.Locked = False
End If

--
Daryl S


"PJ" wrote:

How would I lock multiple fields so a user can not change based on a
click of
a button. There is a date field so once it hit month end I would like
to
freeze a user from changing the record. How is that possible?


Thanks



  #6  
Old May 27th, 2010, 10:44 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Freeze fields with a command button click

PJ -

As Douglas said, you can call the code from a button. If you don't run it
also on the On Current event, then when a user scrolls to a new record, the
formatting won't adjust to the new values. That is why I suggested the
form's On Current event.

--
Daryl S


"PJ" wrote:


Thanks again Daryl. I guess I am not getting this. Would this go on the
form's current event. I wanted a button that I would click on that at any
given time I can click on and it would lock 6 fields and you could only read
them. Where would they below code go?

Thanks!!
"Daryl S" wrote:

PJ -

Use the On Current event so this occurs each time a new record is displayed
(use your fieldnames):

If Me.DateField DateSerial(Year(Date()),Month(Date(),1) Then
Me.Field1.Locked = True
Me.Field2.Locked = True
...
Me.Fieldn.Locked = True
Else
Me.Field1.Locked = False
Me.Field2.Locked = False
...
Me.Fieldn.Locked = False
End If

--
Daryl S


"PJ" wrote:

How would I lock multiple fields so a user can not change based on a click of
a button. There is a date field so once it hit month end I would like to
freeze a user from changing the record. How is that possible?


Thanks

 




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 09:46 PM.


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