 |
| 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
|
|
|
|

December 12th, 2003, 09:51 AM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

December 12th, 2003, 03:41 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

December 13th, 2003, 07:59 AM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

December 13th, 2003, 08:23 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

December 14th, 2003, 08:07 PM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

September 24th, 2004, 08:25 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
convert (... 120)
nitpicking observation... are you using appropiate constant?
thanks,
Howard
[email protected]
|
|
 |