RE: A button question!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi again

Very odd! It's working for me!

You could try only locking the fields if the record isn't new
(as opposed to locking them by default then unlocking them if they are new)

If me.newrecord = false then
<lock fields>
end if

Andy Hull


"scubadiver" wrote:


Private Sub NewRec_Click()

DoCmd.GoToRecord , , acNewRec

End Sub



"Andy Hull" wrote:

Hi

What code do you have behind the button the creates the new record?

Andy Hull

"scubadiver" wrote:


It isn't working for me.

The code I have is

Private Sub Form_Current()

Me.FName.Locked = True
Me.Work.Locked = True
Me.WorkStat.Locked = True
Me.Dept.Locked = True
Me.Subdept.Locked = True
Me.TimeStat.Locked = True
Me.CHours.Locked = True
Me.FName.BackColor = 10079487
Me.WorkStat.BackColor = 10079487
Me.Dept.BackColor = 10079487
Me.Subdept.BackColor = 10079487
Me.TimeStat.BackColor = 10079487
Me.CHours.BackColor = 10079487

If Me.NewRecord = True Then

Me.FName.Locked = False
Me.WorkStat.Locked = False
Me.Dept.Locked = False
Me.Subdept.Locked = False
Me.TimeStat.Locked = False
Me.CHours.Locked = False
Me.FName.BackColor = 16777215
Me.WorkStat.BackColor = 16777215
Me.Dept.BackColor = 16777215
Me.Subdept.BackColor = 16777215
Me.TimeStat.BackColor = 16777215
Me.CHours.BackColor = 16777215

End If

End Sub






"Andy Hull" wrote:

Hi

When you press the button to create the new record this record becomes the
current record thus firing the on current event thus running your code to
"lock" the fields.

In the on current event you will need to test if the record is new. If it
isn't then lock your fields as normal but if it is new then don't lock the
fields.

Use something like...

If Me.NewRecord = False Then...

to decide whether to lock the fields or not.


Regards

Andy Hull








"scubadiver" wrote:


In the current event on my main form, some fields are locked and have a
particular back colour. I have created a button that unlocks the fields and
changes the backcolour to white so the fields are editable (this is so fields
are not changed by mistake).

I also have another button for creating a new record and I want do the same.
Although when I press the button it goes to a new record, I have to press
this button a second time to unlock the fields.
.



Relevant Pages

  • RE: A button question!
    ... Private Sub NewRec_Click ... "Andy Hull" wrote: ... "lock" the fields. ... I have created a button that unlocks the fields and ...
    (microsoft.public.access.forms)
  • RE: A button question!
    ... Private Sub Form_Current ... "Andy Hull" wrote: ... "lock" the fields. ... I have created a button that unlocks the fields and ...
    (microsoft.public.access.forms)
  • Re: Snow Leopard Time Machine wont stay locked
    ... unlocking. ... How does one make the lock "stick"? ... When I go to the Time Machine pref pane, ... Security pref panes setting are locked, ...
    (comp.sys.mac.apps)
  • Re: threaded queue - and cream cheese
    ... the queue is empty and release it when adding to the queue. ... unlocking an unlocked lock, and occaisionally there will be a message ... Threading, and in particular thread synchronization, is not the ...
    (comp.sys.mac.programmer.help)
  • Re: Unlocking a Sony Ericsson P990i?
    ... £15 is a fair price to unlock a "difficult phone" and you will be ... why, when the contract is over, I should pay extra to return the handset to ... Unlocking the phone is NOT difficult for O2, ... Clearly O2 charge this fee in order to lock customers into their ...
    (uk.telecom.mobile)