Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This site is truly a marvel. Without a doubt the most comprehensive, friendly and just plain useful resource of its kind..."

Geography

Where in the world do Tek-Tips members come from?

set ADP form text to value of an SQL user functionHelpful Member! 

bradmaunsell (Programmer)
17 Apr 07 10:10
This should be simple but I cannot figure it out.

I want to set a form text box to the result of an SQL 2005 Express user function.

The function works and returns a value when I execute it from the QUERIES screen in my ADP.

Access Data Project
Access 2003
SQL 2005 Express


For example, behind my form
Forms!frmRating!StdPrem = $5,000
Forms!frmRating!StdPrem = [dbo].[sf_getStdPremium_R2] @Rev, @FeeOnly, etc



set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[sf_getStdPremium_R2]
(
@Rev as dec(7,0),
@FeeOnly as dec(8,4),
@Multi as dec(8,4),
@Claims as dec(8,4),
@SchCred as dec(8,4),
@Affinity as dec(8,4)
)
RETURNS decimal (8,0)
AS
BEGIN
    DECLARE @dblTotalDiscAndSurcharges as dec(8,4)
    DECLARE @dblBasePremium as dec(8,4)
    DECLARE @dblNetPremium as dec(8,4)
    DECLARE @intMinMarkup As int
    If (@FeeOnly) Is Null
        Begin
            set @FeeOnly = 0
        end
    If (@Multi) Is Null
        Begin
            set @Multi = 0
        end
    If (@Claims)Is Null
        Begin
            set @Claims = 0
        end
    If (@Affinity) Is Null
        Begin
            set @Affinity = 0
        end

        set @dblBasePremium = ((@Rev * 0.00812) + 1650)
        If @dblBasePremium < 2250
            Begin
                set @dblBasePremium = 2250
            end
        set @dblTotalDiscAndSurcharges = @FeeOnly + @Multi - @Claims + @SchCred + @Affinity

        set  @dblNetPremium = @dblBasePremium - ((@dblBasePremium) * (@dblTotalDiscAndSurcharges))

        If @dblNetPremium < 2250
            Begin
                set @intMinMarkup = 2250 - @dblNetPremium
                set @dblNetPremium = 2250
            end
        ----Else If
            -----set @intMinMarkup = 0
    
    RETURN @dblNetPremium

END
Helpful Member!  GrahamHills (Programmer)
17 May 07 11:43
try this...

CODE

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

Set rs = CurrentProject.Connection.Execute("SELECT dbo.sf_getStdPremium_R2(2, 0, 2, 2, 2, 2)")

Me.txtFunction = rs(0)
GrahamHills (Programmer)
17 May 07 12:14
Do not need following line:-

CODE

Set rs = New ADODB.Recordset

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close