Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

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
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

try something like

dim strAgent as string
strAgent=Dlookup("CurrentUser", "LOCALtblCurrentUser")

debug.print strAgent

DoCmd.OpenReport "rptReferrals", acViewPreview, , "[Agent] ="" & strAgent & "'"

or this

DoCmd.OpenReport "rptReferrals", acViewPreview, , "[Agent] = '" & DLookup("[CurrentUser]", "LOCALtblCurrentUser") & "'" acWindowNormal
Check the syntax of the DLookup().  What is the --- & "'"  --- before the ending parenthesis?
Avatar of SteveL13

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.
SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial