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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filters, Reports, and Variables

Status
Not open for further replies.

SGElizabeth

Programmer
Nov 5, 2003
6
0
0
US
I am very new to this, so please bear with me! I have a report that shows who placed the order, address, etc., but the data for this report needs to come from two different tables based on the user's id once they've logged in. I was able to do this successfully for a form, but I'm having problems with the report. The report is not seeing the LogonUserID variable, even though the variable is global. Am I not writing the query string correctly? I've tried various ways of filtering, but none seem to work. If I supply an explicit UserID, it works, but it won't use the variable. Help!

Here's the code:

Private Sub Report_Open(Cancel As Integer)
'variable "group" stored at login
If Group = "User" Then
Me.RecordSource = "tblUsers"

Else

Me.RecordSource = "tblUsers"
Me.FilterOn = True

'variable LogonUserID stored at login
DoCmd.ApplyFilter , "UserID = '" & LogonUserID & "'"

End If
End Sub
 
First off, I would not use the word Group as a variable name, as it is a SQL reserved word.

I would store the group value in a single record table when the user logs in and then use dlookup to retrieve the value when it is needed elsewhere.
 
I did not create this app, and I have discovered that there are reserved names used everywhere. Argh!

Thanks--your suggestion worked!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top