Are you saying you always want existing records locked, and only new ones
unlocked?
If so, try:
Private Sub Form_Current()
If Me.NewRecord Then
Me![Drago ID].Locked = False
Me![Drago Claim Number].Locked = False
....
Else
Me![Drago ID].Locked = True
Me![Drago Claim Number].Locked = True
....
End If
End Sub
or
Private Sub Form_Current()
Me![Drago ID].Locked = Not Me.NewRecord
Me![Drago Claim Number].Locked = Not Me.NewRecord
....
End Sub
On the other hand, if you only want them locked if you've clicked on the
button to lock them in the first place, it's a slightly more complicated
proposition (but not that much worse). The trick is, you need to know
whether or not you've already locked the controls. You can put a check
box
on the form (it doesn't have to be visible), and use that to control the
locking. Assuming you named the check box txtLocked (and that it's True
when
they're supposed to be locked, and False when they're supposed to be
unlocked), you can use something like:
Private Sub Form_Current()
If Me.NewRecord Then
Me![Drago ID].Locked = False
Me![Drago Claim Number].Locked = False
....
Else
Me![Drago ID].Locked = Me.txtLocked
Me![Drago Claim Number].Locked = Me.txtLocked
....
End If
End Sub
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I'm sorry, I ment to say next record or any time I left to another
record
I
would want it to auto lock. I want to be able to type when I enter a
new
record. So what would be different from what you told me last post?
Thanks Dustin
:
You'll have to put code in the form's Current event to reset the
Locked
properties.
If you only want the properties reset for new records, use the form's
NewRecord property:
Private Sub Form_Current()
If Me.NewRecord Then
Me![Drago ID].Locked = True
Me![Drago Claim Number].Locked = True
....
End If
End Sub
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I see, I will do that from now on. My last question from my last post
might
have been missed. I wasn't sure on what was the best way to reverse
the
edit
button's command when I go to a new record?
Thanks Dustin
:
Spaces can cause problems when referring to fields or controls:
it's a
nuisance to always have to enclose them in quotes or square
brackets.
Most
of us prefer using Camel Case (PartFailDate, rather than Part Fail
Date).
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Thanks, I got it to work and I understand what I did wrong I need
to
use
the
name of the textbox and not the control source name. See I named
them
different for some reason. Why is should I not use spaces? Just
curious
so
I
understand.
And how do I code it so that when I go to a new record the lock
automatically comes back on?
Thanks so much,
Dustin
:
You still haven't confirmed that the control in question is a
text
box
(or
other control that has a Locked property).
When you're looking in the Properties dialog, what does it say
in
the
Title
of the dialog (the coloured bar above the tabs)?
Try renaming the control (preferably to something without spaces
in
it)
and
then change Me![Part Fail Date].Locked = False to reflect the
new
control
name. Does that make a difference?
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Thanks for responding guys.
I am typing in the control source name that is in the
properties?
And
that
is what I have typed in to the table in Design View. Am I miss
understanding
you guys or am I on the right track? If I am on the right
track
what
do
I
check for next?
Thanks alot
Dustin
:
In Hello,
I am trying to create an edit control for my form. I lock
my
textboxes in properties and then I created a command button
with
an
event on onclick.
My codes are working for most of them expect a few. When I
click
the
button it gives me Run-time error 438. My code is based
liked
this.
Me![Control].Locked=False
Private Sub Edit_Record_Click()
Me![Drago ID].Locked = False
Me![Drago Claim Number].Locked = False
Me![Dealer Claim Number].Locked = False
Me![Dealer].Locked = False
Me![Store].Locked = False
Me![Machine Acres].Locked = False
Me![Part Fail Date].Locked = False - NOT WORKING (debuger
says)
Are you sure that the control [Part Fail Date] is a text box?
Is
it
possible that it's a label?
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)