• Setting the Form.DataEntry mode in code not taking effect

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Setting the Form.DataEntry mode in code not taking effect

    Author
    Topic
    #481848

    I have a subform setup so that when you double click a record selector it opens a form displaying information on that record.

    My issue is that when I set the Form.DataEntry within the forms’ properties window it *acts* like it had no effect. I say it acts like it doesn’t because the Msgbox indicates the setting was changed, but the wrong record opens. In fact, regardless on which record you double click the same one opens, which is the first in the record set. Once I comment out the DataEntry code line it works as long as within the forms’ properties window it is set to False. Form.AllowAdditions setting appears to work fine in code.

    ‘Forms![frmRMA_Repair].Form.DataEntry = False ‘ THIS SETTING DOES NOT WORK IN CODE
    ‘MsgBox Forms![frmRMA_Repair].Form.DataEntry
    Forms![frmRMA_Repair].Form.AllowAdditions = False

    I’m setting this in code because this window is called from other places in the project. Sometimes it’s only to add and other times it’s to open a specific existing record.

    Viewing 1 reply thread
    Author
    Replies
    • #1322230

      Where does this code execute? Is this part of the double click event that opens the form to show a record?
      If so can you show us the full event.

      Normally the form frmRMA_Repair has its data entry property set to True. Is that right?

      I think I would permanently change the data entry property to false.
      When I want to use the form to add a new record use:
      Docmd.Openform stDocname,,,,acFormAdd

      added later

      You can also use
      Docmd.Openform stDocname,,,,acFormEdit
      to convert a Data entry from to one that allows editing of records.
      You would still need to set allow additions to false
      The code I would use for that would be
      Forms(stDocname).AllowAdditions=False

      This all assumes you have a string variable stDocname and you have set it to the name of the form.

    • #1323128

      Hello John. Not sure why but I never got an email indicating that anyone replied, so I never checked back until I got the urge today.

      Yes it’s a double click on the sub form that open the RMA form.

      I wasn’t aware of the acFormAdd and acFormEdit. Looks like you have better more standard and specific way to do it. I’ll give it a try.

      Strange about the failed attempt at setting the DataEntry mode in code. Wanted to do it in case I accidentally changed it in properties at a future date. I like hard coding settings that have a major effect on how a process works, to be safe. Plus its’ a nice and easy to see what’s going on by just viewing the code and not hopping back and forth.

      Thank you!

      Ken

    Viewing 1 reply thread
    Reply To: Setting the Form.DataEntry mode in code not taking effect

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: