OK, I presume you have used the debugger as you have stated that UserName = "". So here is what I would do:
I would check that "Code" has a value, and that the database and the view are being opened properly.
Also, I would declare Code and UserName1 as String instead of Variant, just to be sure (as well as being tidier coding, and using less memory/processing)
Also, I'd replace the "On Error" with
If doc Is Nothing
Also, I would examine the value of the "DisplayName" item in the debugger to check that it's actually there and that its value isn't "".
Hope this helps you solve your problem,
Phil

Feedback response number WEBB8W4LEM created by Phil M Jones on 07/11/2012

Error in code (Meena Ramesh 11.Jul.12)
. . Several things (Rich Schwartz 11.Jul.12)
. . . . Conclusion (Meena Ramesh 12.Jul.12)
. . . . . . The code still got a number of issu... (Karl-Henry Mart... 12.Jul.12)
. . . . I'd click "Like" on this response i... (Phil M Jones 12.Jul.12)
. . Data Types (Pete Burn 11.Jul.12)
. . . . Reply (Meena Ramesh 11.Jul.12)
. . . . . . Try this... (Karl-Henry Mart... 12.Jul.12)
. . . . . . 1 character missing (Phil M Jones 11.Jul.12)
. . . . . . . . Stll problem persists (Meena Ramesh 11.Jul.12)
. . . . . . . . . . Have you tried the debugger? (Phil M Jones 11.Jul.12) |