• Can we edit a textbox in a form opened only for vi (A2K SP3)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Can we edit a textbox in a form opened only for vi (A2K SP3)

    Author
    Topic
    #384698

    My form (Me) which contains several field textboxes and a user-input textbox was set up for viewing only as follows:

    With Me
    .AllowEdits = False
    .AllowAdditions = False
    .AllowDeletions = False
    End With

    Can I still make the input textbox in the form editable? I need to do this as the textbox will receive input from users to navigate to a certain recordset based on the value keyed in. At the moment, user can’t key in anything in the textbox.

    Thanks in anticipation.

    Viewing 0 reply threads
    Author
    Replies
    • #660906

      Instead of setting AllowEdits to False, set it to True and set the Locked property of all bound controls to True. That way, users can type in unbound controls.

      • #661134

        Thanks Hans. Your suggestion works. But looping through all the controls in the form appeared to slow down Access slightly in an old machine. I tried and managed to make the one unbound textbox editable by the codes below, where NotSetEditable is a boolean variable set earlier:

        Private Sub txtUnboundTextBox_GotFocus()

        If NotSetEditable Then
        Me.AllowEdits = True
        End If

        End Sub

        Then I put the similar lines in Form_Current()

        If NotSetEditable Then
        Me.AllowEdits = False
        End If

        It appeared to work and a tad faster. But I am not sure if there is any caveat in my approach.

        Thanks again.

        • #661135

          If you want the bound controls to be locked for editing, and the user-input text box to be editable, you would only need to set the locked property of the bound controls to true once, in design mode – no need to loop through controls in code.

          If you want to switch the entire form between being locked and unlocked, setting AllowEdits to false or true is much more efficient than looping through the controls.

    Viewing 0 reply threads
    Reply To: Can we edit a textbox in a form opened only for vi (A2K SP3)

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

    Your information: