[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 420
  • Last Modified:

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!
0
Sasha42
Asked:
Sasha42
  • 4
  • 3
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
1. in design view of the form, set the property Data Entry No
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
0
 
Sasha42Author Commented:
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.
0
 
Rey Obrero (Capricorn1)Commented:
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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
clarkscottCommented:
The real question becomes... why are you opening a "new record" if the user cannot enter data?.  Perhaps you should precede this function with a "choice form".... "enter new record"  or "view existing record".   This way, you enter the form in a clean fashion.   Otherwise, you really are swimming upstream and making a lot of unnecessary work for yourself.

And... you'll be surpised how many scenarios you (or your users) will find that will require extra tweaks to your code.

Just my 2 cents, here.  You can give me change, if you want.  :-)

Scott C
0
 
clarkscottCommented:
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
0
 
Sasha42Author Commented:
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
0
 
Sasha42Author Commented:
Scott C - I hear you!! I never do this with my other databases.  The client wants the form to open to a blank record.
0
 
Sasha42Author Commented:
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.
0
 
Rey Obrero (Capricorn1)Commented:
<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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now