RE: Conditional display of records ...



Hi Klatuu,

I am trying to specify the UserName in Query and then use the query
in form, its not wokring. It asks for UserName. On launch of my access
project,
I run this form which calls the function to get the username, I move username
to Public variable in the query. But still when I run the query it asks me for
UserName.
My question is how do I call the function in query to get the UserName and
then
do the rest ...

Thank you,
-Me


"Klatuu" wrote:

Here is a function that will return the userid.

Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
Public Function GetUserID()
' Gets the userid (5+2) of the current user.
' Put the following in the declarations section:
'Private Declare Function GetUserNameA Lib "Advapi32" (ByVal strN As String,
ByRef intN As Long) As Long
' modified 4/11/02 dbk set default userid for those not on network

'set default to xxx, changed 10 to 20 for length on 2 lines

Dim Buffer As String * 20
Dim Length As Long
Dim lngresult As Long, userid As String

Length = 20

lngresult = GetUserNameA(Buffer, Length)
If lngresult <> 0 Then
userid = Left(Buffer, Length - 1)
Else
userid = "xxxxxxx"
End If
'MsgBox "USERID = " & userid, , "GetUserID()"
GetUserID = UCase(userid)

End Function


"Me" wrote:

Klatuu,

Yes, I can certainly include the userid in query, what's the syntax to use
the userid?
'cause I am not using Access security, I am using the sql server security.

Or on Form_Current, I can find out who is logged on, at that time is there
any way to modify the criteria?

Thank you for your help!
-Me


"Klatuu" wrote:

Use a query based on the table as the record source of the form. Include a
filter criteria in the query that includes or excludes the flagged records
based on the user id.

"Me" wrote:

I have a form to display records based on a flag in database table.
All users should be able to view records flagged 'N' and
only those users with some particular userid should be able to view
records flagged 'Y'.

What's the best way to achieve this?

Thank you,
-Me

.



Relevant Pages

  • RE: Conditional display of records ...
    ... Also, if there are no arguments passed to a query in a function, it ... The trick is to create a function that calls the username function and pass ... Function CheckFlag(strFlag As String) As Boolean ... ' Gets the userid of the current user. ...
    (microsoft.public.access.formscoding)
  • Re: Oracle SQL Injection vulnerability
    ... The SELECT query doesn't seem to be the one you are injecting since ... likely what you put as a username is stored in a session object and is ... username field and injecting the password field with: ...
    (Pen-Test)
  • RE: How to evade white spaces in a SQL injection
    ... The 2nd one is more likely since they're proably adding the ' character to ... So you'd enter '+1-- as the username. ... +1 tells sql to add 1 to a character field, which it can't do, the -- ... comments out the remainder of the query so it doesn't get parsed. ...
    (Pen-Test)
  • RE: Conditional display of records ...
    ... So in my query, I will map 'A' and 'B' for flag='Y' and userid (with which ... users logon) with the userid stored in table 'B'. ... The trick is to create a function that calls the username function and pass ... Function CheckFlag(strFlag As String) As Boolean ...
    (microsoft.public.access.formscoding)
  • RE: Conditional display of records ...
    ... So in my query, I will map 'A' and 'B' for flag='Y' and userid (with which ... users logon) with the userid stored in table 'B'. ... The trick is to create a function that calls the username function and pass ... Function CheckFlag(strFlag As String) As Boolean ...
    (microsoft.public.access.formscoding)