Sharon
asked on
New record that is locked on open
I have a form that opens to a new record. I do not want the user to enter data into the new record until they click on the New Record button because there is code that automatically populates several fields.
I have tried using dataentry = false on the On Load event. When I do that the first field has Chinese characters in it. I read it is best not to put that code on the On Load event.
How do I lock down the form after it opens a new record? How would I then reverse that when they click on the New Record button.
Thanks!
I have tried using dataentry = false on the On Load event. When I do that the first field has Chinese characters in it. I read it is best not to put that code on the On Load event.
How do I lock down the form after it opens a new record? How would I then reverse that when they click on the New Record button.
Thanks!
ASKER
I set the Data Entry property to No.
When the form is opened a new record created and I can makes changes to it. I don't want the user to make changes to it. Thanks.
When the form is opened a new record created and I can makes changes to it. I don't want the user to make changes to it. Thanks.
if your controls are in a tab control, you can simply disabled-enabled it.
if not you can set the controls locked property to Yes, then in the click event of the New record button, unlocked them..
dim ctl as control
for each ctl in me.controls
if ctl.controltype=actextbox then
me.ctl.locked=false
end if
next
if not you can set the controls locked property to Yes, then in the click event of the New record button, unlocked them..
dim ctl as control
for each ctl in me.controls
if ctl.controltype=actextbox then
me.ctl.locked=false
end if
next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
PS. The secret to great programming is "bottle-necking". One-way-in and One-way-out is the perfect model. Otherwise, you WILL be adding code to a ton of events and working through more "user scenarios" than you're probably getting paid for.
Again.. just my opinion.
Scott C
Again.. just my opinion.
Scott C
ASKER
I have this on the On Load event: (It doesn't lock the text fields.)
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
Me.ctl.Locked = False
End If
Next
DoCmd.GoToRecord , , acNewRec
On Error Resume Next
DoCmd.RunCommand acCmdSaveRecord
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
Me.ctl.Locked = False
End If
Next
DoCmd.GoToRecord , , acNewRec
On Error Resume Next
DoCmd.RunCommand acCmdSaveRecord
ASKER
Scott C - I hear you!! I never do this with my other databases. The client wants the form to open to a blank record.
ASKER
Scott C - I have given it some thought and I agree, I will have a pop up form appear that user has to choose from. Thanks.
<I have this on the On Load event: (It doesn't lock the text fields.)>
off course it will not lock them, to lock the controls you have to use
Me.ctl.Locked = True
off course it will not lock them, to lock the controls you have to use
Me.ctl.Locked = True
2. in the click event of the New record button, place the codes
me.dataentry=true
'your other codes to populate the form go here