Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2005
    Posts
    240

    Unanswered: Help with vba code needed

    Hi

    I'm trying to set two checkboxes in an option group to visible, based on a users login id, which is on another form. I have tried the following code but I can't seem to unhide the checkboxes is there another way to do this?

    Code:
    If [Forms]![frmMenu]![txtUser] <> "KEITHD" And [Forms]![frmMenu]![txtUser] <> "MIKEH" And [Forms]![frmMenu]![txtUser] <> "KEVINB" Then
        Select Case fraReports
        Case 1
        Visible = True
        Case 5
        Visible = True
        End Select
    End If
    Thanks

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    WHAT are you setting visible to true for?

    Code:
        Select Case fraReports 'What is fraReports... a variable?
        Case 1
        YourObjectHere.Visible = True
        Case 5
        YourObjectHere.Visible = True
        End Select
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Sep 2005
    Posts
    240
    What I have done is set two checkboxes in an option group (fraReports) to visible=false.

    I want to make the two checkboxes visible=true, but only when a certain user is logged in, which it picks up from the control on frmMenu (see first line of code I posted).

    fraReports is just the name of the option group, not an ideal name I know.

    I did try without selecting the case, and just had:

    Code:
    If [Forms]![frmMenu]![txtUser] <> "KEITHD" And [Forms]![frmMenu]![txtUser] <> "MIKEH" And [Forms]![frmMenu]![txtUser] <> "KEVINB" Then
    check11.Visible=True
    check55.Visible=True
    End If
    But that didn't work.

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Can we assume that you have a login prompt active (where the user MUST login)? If so, test for your permission using the CurrentUser() method like:

    Select case CurrentUser()
    Case "User1", "User2"
    Check1.Visible=True
    Check2.Visible=True
    End Select
    Back to Access ... ADO is not the way to go for speed ...

  5. #5
    Join Date
    Sep 2005
    Posts
    240
    The user doesn't actually login, I have a module that picks up on the windows login details, and then stores that in a textbox control on the form.

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Have you set a breakpoint at the start of your if statement to evaluate "[Forms]![frmMenu]![txtUser]" ? What was the value?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by KevCB226
    The user doesn't actually login, I have a module that picks up on the windows login details, and then stores that in a textbox control on the form.
    Doesn't matter. Make a string to assign the value to and test that ...
    Back to Access ... ADO is not the way to go for speed ...

Posting Permissions

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