Re: open a form with userlevel criteria



I got lucky and figured this out partially... I used this code...

Dim strCriteria As String
Dim repname As String

repname = CurrentUser()

replogin = DLookup("[rep number]", "Debt Advisors", "[username] ='" & repname
& "'")


strCriteria = "[salesperson] = '" & replogin & "'"

Me.Filter = strCriteria
Me.FilterOn = True

The final problem I am having with this is how can i keep it so the filter
cannot be removed? I do not want my reps to be able to just remove the
filter and then see everyone else's info.

TIA for any help.

Mark Carlyle wrote:
>I want to open my database directly to a form and filter that form to only
>show info pertaining to the user that is currently logged in.
>
>Now I have a User Database that assings a "rep number" to each person.
>
>My forms already sort the data by the "rep number"
>
>What I want to do is compare the CurrentUser() info to the Debt Advisor table
>and find the rep number that matches the current user.
>
>Then filter the current form "greybar" to only show data where the rep number
>of the currentuser = the repnumber of the form.
>
>I hope what I am writing is understandable... thanks in advance for any help.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200508/1
.



Relevant Pages

  • Re: open a form with userlevel criteria
    ... event procedure to modify its RecordSource. ... Dim strRepLogin As String ... >filter and then see everyone else's info. ... >>What I want to do is compare the CurrentUser() info to the Debt Advisor table ...
    (microsoft.public.access.formscoding)
  • Re: special permissions on database
    ... to put quotes around the string that CurrentUser() returns. ... "Joan Wild" wrote: ... String, strUser as String) As Integer Dim ws As WorkSpace ... the manager can only look at his own work. ...
    (microsoft.public.access.security)
  • RE: I know this is simple but I cant find out how...
    ... Note field from null to something, the form thinks both Cell and Note ... PreCity, PreState, PreZip As String ... Private Sub Form_AfterUpdate ... Me.ModifiedBy = CurrentUser() ...
    (microsoft.public.access.modulesdaovba)
  • Re: Query CurrentUser from Outlook View
    ... I believe you'd have to hard-code the CurrentUser name for the DASL for the filter if you are using the Customize View or Define View dialogs unless you are using Outlook 2007. ...
    (microsoft.public.outlook.program_vba)
  • Re: Password for CurrentUser()
    ... Doug Steele, Microsoft Access MVP ... username As String, ByVal passwordAnswer As String) As String ... can I know the password of CurrentUser()? ...
    (microsoft.public.access.security)