Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2011
    Posts
    6

    Question Unanswered: Microsoft Access 2003

    hi,
    I'm new to this forum but have viewed other posts and got great help.
    I have used access before for query/reports/macros etc., but not so much on the front end i.e. forms so I am a bit stuck.

    I have set up a form on opening the database to pick up the windows user login and then specified each user with a "status" i.e. either Administrator, Coordinator or Analyst. This then points them to another form specific to their user "status". For example an Analyst opens the "Workload" Form which should display a list of their scheduled reports. At the moment this form is displaying all reports in the schedule for all analysts so it is not specific to the user who logged in.

    How can I get this to only display the scheduled reports for the user who logged into the database. The forms are continuous form/ tabular for display purpuses and are run off a query.

    I hope this make sense. Any help would be great.

    tx

    fiona

  2. #2
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    You can set the underlying query just to show results for the logged in user. Simply add the function that returns to the user information to its WHERE clause:
    Code:
    SELECT SomeColumns
    FROM tblReportsInProgress
    WHERE AssignedUser = GetUserID();
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  3. #3
    Join Date
    Apr 2011
    Posts
    6

    Question

    hi
    thanks for getting back so quickly
    I tried that in the query WHERE clause
    AND (([ANALYST SCHEDULE].UMUNAM)= UserName())

    It brings back Undefined Function 'UserName' in expression.

    here is the function on the form when we login into the database.

    ' Return the user's name.
    Private Function UserName() As String
    Const UNLEN = 256 ' Max user name length.
    Dim user_name As String
    Dim name_len As Long

    user_name = Space$(UNLEN + 1)
    name_len = Len(user_name)
    If GetUserName(user_name, name_len) = 0 Then
    UserName = "<unknown>"
    Else
    UserName = Left$(user_name, name_len - 1)
    End If
    End Function

    Should the database not recognise this function?

    always appreciate the help

    tx
    fiona

  4. #4
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    Whereabouts is the function defined? If it's in the code module of the login form, it won't be visible to any other part of the database. In that case, I'd recommend moving it to a normal code module, and making it public.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  5. #5
    Join Date
    Apr 2011
    Posts
    6

    Smile

    oh thanks a mill got that sorted, all working now.
    I'm sure I'll have many more questions

    thanks again

    always appreciate the help

    tx
    fiona

  6. #6
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    You're welcome and good luck!
    10% of magic is knowing something that no-one else does. The rest is misdirection.

Posting Permissions

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