SGElizabeth
Programmer
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
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