RE: A button question!
- From: Andy Hull <AndyHull@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 11 Jul 2007 07:36:02 -0700
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.
- References:
- RE: A button question!
- From: scubadiver
- RE: A button question!
- From: Andy Hull
- RE: A button question!
- From: scubadiver
- RE: A button question!
- Prev by Date: RE: A button question!
- Next by Date: Re: Form auto-fill linking
- Previous by thread: RE: A button question!
- Next by thread: RE: A button question!
- Index(es):
Relevant Pages
|