Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2003, 09:51 AM
Registered User
 
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access List Box & stored procedure with parameters

I currently have an Access 2000 ADP form which is being supplied by a string variable s which contains the name of the stored
Procedure and its paramters
(e.g s = sp_Prn_IC @sdtStart= '2002-12-12' , @sdtEnd= '2003-12-12' , @InvType= 'I' , @AmountFrom= 0 , @AmountTo= 999999.99)
Please note that I can run this string directly under SQL Query Analyzer with no problems.
In the form I have a List 'QItems' and I do not know how to supply the List with above string s.
The List displays blank screen.
I have a relevant subroutine :

'' ===========
Private Sub QItems1_Enter()
    Me.QItems.RowSourceType = "Table/View/StoredProc"
    Me.QItems.RowSource = s
    Me.QItems.ColumnCount = 13
    Me.QItems.ColumnHeads = True
    Me.QItems.Requery
End Sub

'' ===========
(N.B. under debug shows the value of s correctly. )

The Stored Procedure is :
-- =========
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

ALTER PROCEDURE sp_Prn_IC
(@InvType nvarchar(1),
@sdtStart VARCHAR(10), -- yyyy-mm-dd
@sdtEnd VARCHAR(10), -- yyyy-mm-dd
@AmountFrom float =NULL,
@AmountTo float =NULL)
AS
DECLARE @dtStart AS datetime
DECLARE @dtEnd AS datetime

SET NOCOUNT ON

SET @dtStart = cast(@sdtStart AS DATETIME )
SET @dtEnd = cast(@sdtEnd AS DATETIME )
SELECT dbo.tblInvoices.InvNum, dbo.tblInvoices.InvoiceDate,
                      dbo.tblInvoices.AccCode, dbo.tblInvoices.AccName, dbo.tblInvoices.Amount,
                      dbo.tblAddress.ADDCODE, dbo.tblAddress.Address1, dbo.tblAddress.Address2,
                      dbo.tblAddress.Address3, dbo.tblAddress.Address4, dbo.tblAddress.Address5,
                      dbo.tblAddress.Postcode, dbo.tblInvoices.PrintInvoice
FROM dbo.tblInvoices
INNER JOIN
             dbo.tblAddress ON dbo.tblInvoices.AddressID = dbo.tblAddress.ID
WHERE (CONVERT(NVARCHAR(10), dbo.tblInvoices.InvoiceDate, 120) BETWEEN @dtStart AND @dtEnd ) AND
      (dbo.tblInvoices.InvType = @InvType) AND
          ( dbo.tblInvoices.Amount BETWEEN @AmountFrom AND @AmountTo)
ORDER BY dbo.tblInvoices.InvNum

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
-- =============

(N.B. under debug shows the value of s correctly. )

Any help will be greatly appreciated.

Narendra Rathod

Narendr Rathod
 
Old December 12th, 2003, 03:41 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try changing
Code:
 s = "sp_Prn_IC @sdtStart= '2002-12-12' , @sdtEnd= '2003-12-12' , @InvType= 'I' , @AmountFrom=  0 , @AmountTo=  999999.99"
to
Code:
 s = "EXEC dbo.sp_Prn_IC @sdtStart= '2002-12-12' , @sdtEnd= '2003-12-12' , @InvType= 'I' , @AmountFrom=  0 , @AmountTo=  999999.99"

Brian Skelton
Braxis Computer Services Ltd.
 
Old December 13th, 2003, 07:59 AM
Registered User
 
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Brian,

I have tried as shown:
EXEC dbo.sp_Prn_IC @sdtStart= '2002-12-13' , @sdtEnd= '2003-12-13' , @InvType= 'I' , @AmountFrom= 0 , @AmountTo= 999999.99
and no Luck.

Many thanks

Narendra Rathod

Narendr Rathod
 
Old December 13th, 2003, 08:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is the owner of the stored procedure dbo?

Try leaving the owner out and see if that makes a difference.


Brian Skelton
Braxis Computer Services Ltd.
 
Old December 14th, 2003, 08:07 PM
Registered User
 
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Brian,

I promise you I have tried these minor variations which you mention and had no luck as the sample shows below:
EXEC sp_Prn_IC @sdtStart= '2002-12-14' , @sdtEnd= '2003-12-14' , @InvType= 'I' , @AmountFrom= 0 , @AmountTo= 999999.99.

Over the weekend I had to caught out some serious money at London’s bookstores to seek a cure and will let you know when I have found it.

Many thanks.
 
Old September 24th, 2004, 08:25 AM
Registered User
 
Join Date: Sep 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

convert (... 120)

nitpicking observation... are you using appropiate constant?


thanks,

Howard
[email protected]





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored Procedure Parameters Blank brettdalldorf Crystal Reports 0 September 20th, 2007 02:17 AM
Odbc Parameters Stored Procedure jgrant ASP.NET 2.0 Basics 2 August 26th, 2007 10:21 PM
One textbox, Two Parameters, with Stored Procedure GailCG Classic ASP Professional 0 March 3rd, 2006 03:39 PM
Calling Stored Procedure with parameters zarina_24 Classic ASP Professional 4 March 2nd, 2006 11:57 AM
stored procedure with parameters Danmalam VB Databases Basics 0 February 27th, 2005 03:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.