• Disabling fields on forms (Access 2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Disabling fields on forms (Access 2003)

    Author
    Topic
    #429034

    I have a form where I am calculating two fields and the rest are user entry fields. I want to keep the calculated fields as view only fields that the user can not access. I have the calculated fields set as Enabled = No and Locked = Yes. The first field that is a pure calculation

    Viewing 3 reply threads
    Author
    Replies
    • #998188

      Have you set the Tab Stop property to No?

    • #998198

      And are you sure that you have set the Enabled and Locked properties for the second text box? From your description I would guess that you have only set them correctly for the first text box.

    • #998218

      I agree with HansV – sounds to me like you have the Locked property set to Yes, but somehow you neglected to set the Enabled property to No. I don’t believe SteveH’s suggestion of turning off the Tab stop property will make any difference – my databases have lots of locked fields, some permanently locked and some locked and unlocked in code, and I don’t think I have ever played with the Tab stop property – if a field isn’t enabled there’s no way you can tab to it.

    • #998233

      I had missed the tab stop setting and setting it as suggested corrects the issue with landing on the field when tabbing or hitting enter. I can still click on the field and access the field enough that it displays the underlying numeric value instead of the Yes, No value. Interestingly if I leave the settings as Enabled = No, Locked = Yes and Tab Stop = Yes like the first field that is working correctly and just change the source to the same calculated value as the first field, then the second field also works just like the first field. If I put the Iif code back in it goes back to being accessible. The Iif statement seems to be a contributing factor

      • #998237

        What you describe is very strange – the settings Enabled = No and Locked = Yes should work regardless of the control source of the text box: it shouldn’t matter whether the text box is bound to a field, is calculated or has a blank control source.

        • #998281

          Actually I have an unbound text box on a form that has Enabled set to false and Locked set to true and tab stop set to false, and it still allowsme to click in the box and change the value.

          It is populated in the On Current event.

          • #998284

            Do you have conditional formatting set for this text box? That seems to play strange tricks with the Enabled property of a text box.

            • #998286

              Where do I check if conditional formatting is set for the text box?

              I inherited this database to be fixed.

            • #998289

              – Open the form in design view.
              – Select the text box by clicking on it.
              – Select Format | Conditional Formatting…
              – If everything under Condition 1 is blank, no conditional formatting has been set.
              – If a condition has been entered, and formatting has been set, you will notice it.

            • #998292

              Thanks Hans,

              No it doesn’t have conditional formatting.

              Unless you have any other ideas, it seems like I will have to trap the OnGotFocus and go to the previous control that had the focus. How would I do this?

            • #998293

              The code would look like

              Private Sub txtProblem_GotFocus()
              Screen.PreviousControl.SetFocus
              End Sub

              where txtProblem is the offending text box.

            • #998294

              It’s ok, I found it in post 535990, thank you. grin

            • #998304

              Is this the best solution for this scenario?

            • #998306

              Personally, I would investigate if I could reproduce the problem in a newly created form. If not, I would suspect the problem form to be more or less corrupt, and I would copy all database objects except the form to a blank new database, and recreate the problem form from scratch.

            • #998307

              This form is a modification of a terrible form in a database that I inherited. If I try to create a control at the moment it shows 708 as the number of the text box it is creating. The maximum number of controls in a form is 754 as you said in an earlier post.

              I might have to recreate the form as you said.

          • #998320

            If enabled is set to false, you should NOT be able to click into the control, let alone change the data. I would hunt for code setting the enabled property of the form’s controls.

            • #998323

              Good call Charlotte.

              I had forgotten that depending on the User I either Enable or Disable all controls on the form except command buttons. This must be the problem, I will prove it by using Debug.Print to see if the control is enabled. It was enabling it.

              Thanks again Charlotte for making me go open my eyes.

              I think I will leave the OnGotFocus code that forces the user back to the previous control. I have changed it to disable the 2 controls and delete the OnGotFocus code.

    Viewing 3 reply threads
    Reply To: Disabling fields on forms (Access 2003)

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

    Your information: