Access 2000v Error in user defined function

  • Thread starter Thread starter Emmanuel
  • Start date Start date
E

Emmanuel

Access cannot execute user defined functions on reports.
I am using the following simple function in report code:

Function doit() as string
Dim str as string
str = Me![UserName] & " " & Me![UserID]
doit = str
End Function

Then I put a tsxtbox on my report and set its Control
Source property to =doit()

Access returns with an error message that it can't find
the field 'UserName' I have set the Record source of the
report to the appropriate table. If you simply
put 'UserName' as the Control source it works. What is
going on here. I will appreciate your help

Emmanuel
 
You would need to bind the UserName field to a control in order to reference
its value in code. I am confused why you would not use a text box with its
control source set to:
=[UserName] & " " & [UserID]
 
Yes, I knew I could do that but I posted a simple example
to illustrate a complex text that will involve
conditional statements. Thanks for your response though.

Emmanuel
-----Original Message-----
You would need to bind the UserName field to a control in order to reference
its value in code. I am confused why you would not use a text box with its
control source set to:
=[UserName] & " " & [UserID]

--
Duane Hookom
MS Access MVP


Emmanuel said:
Access cannot execute user defined functions on reports.
I am using the following simple function in report code:

Function doit() as string
Dim str as string
str = Me![UserName] & " " & Me![UserID]
doit = str
End Function

Then I put a tsxtbox on my report and set its Control
Source property to =doit()

Access returns with an error message that it can't find
the field 'UserName' I have set the Record source of the
report to the appropriate table. If you simply
put 'UserName' as the Control source it works. What is
going on here. I will appreciate your help

Emmanuel


.
 
Back
Top