473,503 Members | 6,354 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access ADP and Stored Procedure Did not Return Any Records

2 New Member
Access ADP and Stored Procedure Did not Return Any Records
Access 2002 and SQL 2000 Server

I have a form named "Selector", and it have four combo boxes and a subform named
Q_FilteringQuery_subform. When any of the combo box is selected, the code will
call a VBA procedure which will then activate the stored procedure named Get_Records_For_Selector_Form.
When I first select an item from the combo box Dept while all three other combo boxes are blank,
I got an error message:
Error Message "P1 is not a parameter for procedure Get_Records_For_Selector_Form"

Because of the error, no new records is displayed on the subform "Q_FilteringQuery_subform".

////////////////////////////////////////////////////////////////////////////////////////////////////////////

Private Sub Activate_Stored_Procedure_To_Obtain_Records_For_Se lector_Form()
Dim SQL_Form As String
Dim strStep As String

SQL_Form = "Exec [Get_Records_For_Selector_Form] "
strStep = ""

If Not IsNull(Forms!Selector!From_Date) And Not IsNull(Forms!Selector!To_Date) Then
SQL_Form = SQL_Form & strStep & " @From_Date = " & "'" & Me.From_Date & "'"
strStep = ","
SQL_Form = SQL_Form & strStep & " @To_Date = " & "'" & Me.To_Date & "'"
strStep = ","
End If

If Not IsNull(Me.Dept) Then 'Department
SQL_Form = SQL_Form & strStep & " @Department = " & "'" & Me.Dept & "'"
strStep = ","
End If

If Not IsNull(Me.so) Then 'SO_Number
SQL_Form = SQL_Form & strStep & " @SO_Number = " & "'" & Me.so & "'"
strStep = ","
End If

If Not IsNull(Me.Item) Then 'Item_Number
SQL_Form = SQL_Form & strStep & " @Item_Number = " & "'" & Me.Item & "'"
strStep = ","
End If

If Not IsNull(Me.Sectionno) Then 'Section_Number
SQL_Form = SQL_Form & strStep & " @Section_Number = " & "'" & Me.Sectionno & "'"
strStep = ","
End If

Me.Q_FilteringQuery_subform.Form.RecordSource = SQL_Form
End Sub

////////////////////////////////////////////////////////////////////////////////////////////////////////////

The stored procedure named Get_Records_For_Selector_Form
asked for 6 optional parameters.

CREATE PROCEDURE Get_Records_For_Selector_Form
@From_Date smalldatetime = Null, @To_Date smalldatetime = Null,
@Department int = Null, @SO_Number int = Null,
@Item_Number varchar(10) = Null,
@Section_Number nvarchar(3) = Null

AS SELECT DISTINCT [1_Job - Parent].SONumber, [1_Job - Parent].Department_Name, [1_Job - Parent].ItemNumber, [1_Job - Parent].SectNumber, [1_Job - Parent].RecordInitiateDate, [1_Job - Parent].MechUser, [1_Job - Parent].ElecUser, [1_Job - Parent].GreenTagUser, [1_Job - Parent].GreenTagDate, Ref_DepartmentID.ID
FROM Ref_DepartmentID RIGHT JOIN [1_Job - Parent]
ON Ref_DepartmentID.ID = [1_Job - Parent].DepartmentID
WHERE @From_Date >= isnull( @From_Date, dbo.[1_Job - Parent].RecordInitiateDate)
AND @To_Date <= isnull( @To_Date, dbo.[1_Job - Parent].RecordInitiateDate)
AND dbo.Ref_DepartmentID.ID = isnull(@Department, dbo.Ref_DepartmentID.ID)
AND SONumber = isnull(@SO_Number, dbo.[1_Job - Parent].SONumber)
AND ItemNumber = isnull(@Item_Number, dbo.[1_Job - Parent].ItemNumber)
AND SectNumber = isnull(@Section_Number, dbo.[1_Job - Parent].SectNumber)
ORDER BY [1_Job - Parent].RecordInitiateDate DESC
GO
Mar 11 '08 #1
1 1779
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. All of what you have listed seems OK, at least as far as can be determined by checking the lines as written. As the error is occurring when you select a value from the department combo, could you supply the After Update code for this control? It may be that the After Update is doing something that would explain why you receive the message referring to P1 which does not appear in the code you have supplied.

-Stewart
Mar 16 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
6678
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
0
4471
by: ImraneA | last post by:
Hi there I had pleasure of upsizing Access v97 db to Access v2K/SQL 2K. Wish to provide some knowledge gained back to community - hopefully help others. 1.Question how do you test stored...
3
3683
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what...
1
361
by: Neil | last post by:
Hello, I have a SQL Server 2000 database with an Access 97 front end. I want to run stored procedures, (not nessessarily ones which return records either - action type queries for adding new...
2
2023
by: Noloader | last post by:
Hello, Access XP, SQL Server 2000 Is it possible to hide a SP under Queries in Access, yet still be able to Execute it from Access? (Similar to hiding Tables, then using Views) We hooked...
1
1551
by: Wim van Rosmalen | last post by:
Hi folks, I've upgraded MS-Access 2002 to a MS-Access Project (adp), so now I have to deal with more sophisticated queries (may I call them so?) like stored procedures. I have a form with a...
1
5710
by: Sreeneet | last post by:
Hi all, I want to call a stored procedure which is written in SQL Server from an ms-access query. It is having some parameters also and the stored procedure will return some records. Is there...
10
2341
by: Hank | last post by:
We have just recently migrated the data from our Access 2000 backend to Postgres. All forms and reports seem to run correctly but, in many cases, very slowly. We do not want to switch over until...
8
4392
by: adserte | last post by:
I have a security related question. I was wondering how i can set up security so that for a table: a user can read all data in the table but only update and delete their own data (there is a...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7012
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
402
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.