Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jan 2003
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hide form controls except for 1 user (Access 2000)

    I have a simple database with only 1 table and 1 form. I need all users to see the form with all controls except for 2, which I have changed the Visible property of the 2 controls to "No." However, I need the controls to become visible for one user only, the boss, where he can indicate his appoval (y/n field) and his comments (text field). Is there a way to run a macro from the keyboard that will make the two controls visible for the boss, who would be the only one who knows the keyboard shortcut, e.g., Alt/Ctrl/V, etc.? Or does anyone have any other ideas how I can accomplish this task? Note: Only 10 users and no security on the database. It is located on network drive and has not been split (and I really don't want to have to split the database if I can help it). Many thanks...Mary

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

    Re: Hide form controls except for 1 user (Access 2000)

    1. Set the Key Preview property of the form to Yes (you'll find it in the Events tab of the Properties window). This means that all keyboard events will be raised at the form level before being raised at the control level, so you can handle them at the form level if needed.

    2. Write code in the On Key Down event of the form (I don't know how to do this with a macro):

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If (Shift And acAltMask > 0) And (Shift And acCtrlMask) > 0 And KeyCode = vbKeyV Then
    Me.txtSomethingElse.SetFocus
    Me.chkApproval.Visible = Not Me.chkApproval.Visible
    Me.txtComment.Visible = Not Me.txtComment.Visible
    End If
    End Sub

    chkApproval and txtComment should be replaced by the names of the controls to be shown. The code above will actually toggle the visibility of these controls, and since you can't hide a control that has the focus (i.e. is the active control), another control is made active before doing so; substitute the appropriate name.

  3. #3
    2 Star Lounger
    Join Date
    Jan 2003
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide form controls except for 1 user (Access 2000)

    Hello, Hans...I

Posting Permissions

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