Solved

SQL Server Scalar UDF as report textbox controlsource

Posted on 2013-01-10
3
570 Views
Last Modified: 2013-01-10
I have a Scalar UDF in SQL Server that returns a single value for a passed parameter.

I have an MS Access mdb that uses that links to the SQL Server.

I have a report where I want to bind a textbox to the UDF. Is that possible?

If not, how would I write a VBA function that calls the UDF and returns the value?

While waiting for an answer, I am going to look to see if I'm able to just include the UDF in the SQL Server recordsource that the report is already using. That would be a much cleaner solution. But, in case I can't do that, I'd like an answer to the above.

Thanks!
0
Comment
Question by:Kaprice
  • 2
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 38762115
>I want to bind a textbox to the UDF.
as you need some parameter, I don't see how that could work out.
also, a textbox is for "data input", while UDF refers to "data display only", so you eventually want to say "label" instead, or at least a read-only textbox.

>If not, how would I write a VBA function that calls the UDF and returns the value?
like any other sql query you would run towards the sql server:
select dbo.Your_UDF(<parameter)
the question is: do you already have the connection part in the VBA? what exactly would you need there?

>I am going to look to see if I'm able to just include the UDF in the SQL Server recordsource that the report is already using.
sure. you can add a UDF function in a select
0
 

Author Comment

by:Kaprice
ID: 38763720
as you need some parameter, I don't see how that could work out.
 
Well, it would be very straightforward if it were an Access function. In the control's controlsource, I would put "=myfunction(txtOtherControl)"
a textbox is for "data input", while UDF refers to "data display only", so you eventually want to say "label" instead, or at least a read-only textbox.
They still call it a textbox in  a report, even if it's for display only. At least I use the same texbox control from the toolbox.
select dbo.Your_UDF(<parameter)
If adding it directly to the report's recordsource, I'll try this.
I'll report back later today.
Thanks.
0
 

Author Closing Comment

by:Kaprice
ID: 38766147
I was able to add the function to the select statement in SQL Server that was the report's recordsource.

Expert's answer gave me confidence with options to try.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now