Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Feb 2002
    Posts
    155
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

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

    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.

  3. #3
    2 Star Lounger
    Join Date
    Feb 2002
    Posts
    155
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

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

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •