Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can this be done? Do I need to create a UFL?

Status
Not open for further replies.

BradB

MIS
Jun 21, 2001
237
US
I have a module in VB6 that retreives the Windows NT/2000 logon name and holds it. I use the GetWindowsLoginUserID() in my RDC Crystal Control to check the users login name. Then, the program checks a database to see what reports the user can access.

I now have a request to limit the reports searching ability to only THEIR login name. As it is now, once they have access to the report, they can access information on anyone if they have the other users ID. I want my reports to look at the GetWindowsLoginUserID() and run reports based on that. Do I need to create a UFL?


'Modeule to get the users Logon Name
Option Explicit

Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long
Public Function GetWindowsLoginUserID() As String
Dim rtn As Long
Dim sBuffer As String
Dim lSize As Long

sBuffer = String$(260, Chr$(0))
lSize = Len(sBuffer)
rtn = GetUserName(sBuffer, lSize)
If rtn Then
sBuffer = Left$(sBuffer, lSize)

'Reformat string
If InStr(sBuffer, Chr$(0)) Then
sBuffer = Left$(sBuffer, InStr(sBuffer, Chr$(0)) - 1)
End If

GetWindowsLoginUserID = sBuffer
Else
'Error!
GetWindowsLoginUserID = ""
End If
frmMain.Show
End Function
 
Almost on the right track.

I think a COM data source will solve your problem.

What you are trying to do is control the data source depending on parameters the user enters. UFL's are processed after the data is retrieved, while a COM data source is processed earlier.

Create a COM Data Provider as a DLL, and then use that as an ADO source for your report. Email me directly (bruce@chelseatech.co.nz) if you have any further questions as I'm writing some code to learn that technique at the moment.
Editor and Publisher of Crystal Clear
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top