SteveL13
asked on
Error can't find table ??
I am trying to open a report filtered by the current user. But I'm getting an error saying the d/b can't find the table or it is misspelled. It is spelled correctly. Do I have a syntax issue with this code...
DoCmd.OpenReport "rptReferrals", acViewPreview, , "[Agent] = '" & DLookup("[CurrentUser]", "LOCALtblCurrentUser" & "'"), acWindowNormal
DoCmd.OpenReport "rptReferrals", acViewPreview, , "[Agent] = '" & DLookup("[CurrentUser]", "LOCALtblCurrentUser" & "'"), acWindowNormal
Check the syntax of the DLookup(). What is the --- & "'" --- before the ending parenthesis?
ASKER
Rey,
I am trying your first suggestion but am getting "Syntax error in string in query expression '[Agent] =" & strAgent & '
The degug.print returns the correct string of characters.
I am trying your first suggestion but am getting "Syntax error in string in query expression '[Agent] =" & strAgent & '
The degug.print returns the correct string of characters.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
dim strAgent as string
strAgent=Dlookup("CurrentU
debug.print strAgent
DoCmd.OpenReport "rptReferrals", acViewPreview, , "[Agent] ="" & strAgent & "'"
or this
DoCmd.OpenReport "rptReferrals", acViewPreview, , "[Agent] = '" & DLookup("[CurrentUser]", "LOCALtblCurrentUser") & "'" acWindowNormal