473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How to load records into a subform using stored procedure

2
Access 2003. SQL 2000 Server

The procedure Activate_Stored_Procedure_To_Obtain_Rows_For_Combo
load all of the record in the four combo boxes correctly.

When I select one of the combo boxes, the procedure
Activate_Stored_Procedure_To_Obtain_Rows_For_Subfo rm crashed at
the code Me.Selector_Sub_Form.Form.RecordSource = SQL_Subform

Run-Time error 8145
P1 is not a parameter for procedure Obtain_Records_For_Subform_Selector.

The YELLOW HIGLIGHT IS at the code
Me.Selector_Sub_Form.Form.RecordSource = SQL_Subform

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

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Me.Dept = Null
  3. Me.so = Null
  4. Me.Sectionno = Null
  5. Me.Item = Null
  6.  
  7. Me.Dept.RowSource = "Exec [get_Dept_ID]"
  8. Me.Selector_Sub_Form.Form.RecordSource =
  9. "Exec [Obtain_Records_For_Subform_Selector]"
  10. End Sub
  11.  
  12. //////////////////////////////////
  13.  
  14. Private Sub Dept_AfterUpdate()
  15. Call Activate_Stored_Procedure_To_Obtain_Rows_For_Combo
  16. End Sub
  17.  
  18. Private Sub SO_AfterUpdate()
  19. Call Activate_Stored_Procedure_To_Obtain_Rows_For_Combo
  20. End Sub
  21.  
  22. Private Sub Item_AfterUpdate()
  23. Call Activate_Stored_Procedure_To_Obtain_Rows_For_Combo
  24. End Sub
  25.  
  26. Private Sub Sectionno_AfterUpdate()
  27. Call Activate_Stored_Procedure_To_Obtain_Rows_For_Combo
  28. End Sub
  29.  
  30. /////////////////////////////
  31.  
  32. This procedure does work.
  33.  
  34. Private Sub Activate_Stored_Procedure_To_Obtain_Rows_For_Combo()
  35.  
  36. Dim SQL_Department As String
  37. Dim SQL_SO As String
  38. Dim SQL_Item As String
  39. Dim SQL_Section As String
  40. Dim strStep As String
  41.  
  42. SQL_Department = "Exec [Get_Department_1] "
  43. SQL_SO = "Exec [Get_SO_Number_1] "
  44. SQL_Section = "Exec [Get_Section_Number_1] "
  45. SQL_Item = "Exec [Get_Item_Number_1] "
  46. strStep = ""
  47.  
  48. If Not IsNull(Me.Dept) Then 'Department
  49. 'SQL_From_Date = SQL_From_Date & strStep & " @From_Date = " & "'" & Me.From_Date & "'"
  50. 'SQL_To_Date = SQL_To_Date & strStep & " @To_Date = " & "'" & Me.To_Date & "'"
  51.  
  52. SQL_Department = SQL_Department & strStep & " @Department = " & "'" & Me.Dept & "'"
  53. SQL_SO = SQL_SO & strStep & " @Department = " & "'" & Me.Dept & "'"
  54. SQL_Item = SQL_Item & strStep & " @Department = " & "'" & Me.Dept & "'"
  55. SQL_Section = SQL_Section & strStep & " @Department = " & "'" & Me.Dept & "'"
  56. strStep = ","
  57. End If
  58.  
  59. If Not IsNull(Me.so) Then 'SO_Number
  60. SQL_Department = SQL_Department & strStep & " @SO_Number = " & "'" & Me.so & "'"
  61. SQL_SO = SQL_SO & strStep & " @SO_Number = " & "'" & Me.so & "'"
  62. SQL_Item = SQL_Item & strStep & " @SO_Number = " & "'" & Me.so & "'"
  63. SQL_Section = SQL_Section & strStep & " @SO_Number = " & "'" & Me.so & "'"
  64. strStep = ","
  65. End If
  66.  
  67. If Not IsNull(Me.Item) Then 'Item_Number
  68. SQL_Department = SQL_Department & strStep & " @Item_Number = " & "'" & Me.Item & "'"
  69. SQL_SO = SQL_SO & strStep & " @Item_Number = " & "'" & Me.Item & "'"
  70. SQL_Item = SQL_Item & strStep & " @Item_Number = " & "'" & Me.Item & "'"
  71. SQL_Section = SQL_Section & strStep & " @Item_Number = " & "'" & Me.Item & "'"
  72. strStep = ","
  73. End If
  74.  
  75. If Not IsNull(Me.Sectionno) Then 'Section_Number
  76. SQL_Department = SQL_Department & strStep & " " & " @Section_Number = " & "'" & Me.Sectionno & "'"
  77. SQL_SO = SQL_SO & strStep & " @Section_Number = " & "'" & Me.Sectionno & "'"
  78. SQL_Item = SQL_Item & strStep & " @Section_Number = " & "'" & Me.Sectionno & "'"
  79. SQL_Section = SQL_Section & strStep & " @Section_Number = " & "'" & Me.Sectionno & "'"
  80. strStep = ","
  81. End If
  82.  
  83. Me.Dept.RowSource = SQL_Department
  84. Me.so.RowSource = SQL_SO
  85. Me.Item.RowSource = SQL_Item
  86. Me.Sectionno.RowSource = SQL_Section
  87.  
  88. Call Activate_Stored_Procedure_To_Obtain_Rows_For_Subform
  89. End Sub
  90.  
  91. /////////////////
  92.  
  93. This procedure causes a crash.
  94.  
  95. Private Sub Activate_Stored_Procedure_To_Obtain_Rows_For_Subform()
  96. Dim SQL_Subform As String
  97. Dim strStep As String
  98.  
  99. SQL_Subform = "Exec [Obtain_Records_For_Subform_Selector]"
  100. strStep = ""
  101.  
  102. If Not IsNull(Me.Dept) Then 'Department
  103. SQL_Subform = SQL_Subform & " @Department = " & "'" & Me.Dept & "'"
  104. strStep = ","
  105. End If
  106.  
  107. If Not IsNull(Me.so) Then 'SO_Number
  108. SQL_Subform = SQL_Subform & strStep & " @SO_Number = " & "'" & Me.so & "'"
  109. strStep = ","
  110. End If
  111.  
  112. If Not IsNull(Me.Item) Then 'Item_Number
  113. SQL_Subform = SQL_Subform & strStep & " @Item_Number = " & "'" & Me.Item & "'"
  114. strStep = ","
  115. End If
  116.  
  117. If Not IsNull(Me.Sectionno) Then 'Section_Number
  118. SQL_Subform = SQL_Subform & strStep & " @Section_Number = " & "'" & Me.Sectionno & "'"
  119. strStep = ","
  120. End If
  121.  
  122. Me.Selector_Sub_Form.Form.RecordSource = SQL_Subform
  123.  
  124. End Sub
  125.  
Apr 27 '11 #1
0 1019

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

Similar topics

4
by: marc | last post by:
I've been developing a stored procedure that uses a user defined function in the query portion of the procedure. However, since the end product needs to allow for dynamic table names, the UDF will...
2
by: Paul Hale | last post by:
Hi all, being new to c# I'm trying to find the best way of passing multiple records to insert into a sql database via a stored procedure. I'm using visual studio 2005 RC SQL server 2005 and C# of...
9
by: joun | last post by:
Hi all, i'm using this code to insert records into an Access table from asp.net, using a stored procedure, called qry_InsertData: PARAMETERS Long, Long, Text(20), Long, DateTime; INSERT...
1
by: deepdata | last post by:
Hi, I am trying to fetch data from db2 (express version) database by calling stored procedure. I have tried to use both cursor and for loop but still i am getting error. --======Start...
2
by: Godzilla | last post by:
Dear all, I have a challenge in hand and am not too sure how to accomplish this using stored procedure. I have a table containing about 3 fields, but I need to reorder/renumber a field value...
1
hariharanmca
by: hariharanmca | last post by:
How to Shift or Copy Data from Sqlserver to MS Access using Stored procedure I am passing the clint MS Access file path in that i want to insert or update data in that MS Access file using...
0
by: Srireddy | last post by:
Hi all, I am trying to read an xml using stored procedure and upload it in to the DB. I am using DB2 v8.0. can anyone help me complete my assignment... Thanks in advance..
1
by: madhuparimi | last post by:
I am working on jasper reports.First i want to know how to generate a ireport using stored procedure. Can u please help me out and tell me how to generate an ireport using stored procedure
2
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
2
by: hemantc87 | last post by:
i have created this function with a parameter offset and i want to access the database using stored procedure but the code and stored procedure i have written below is not working...what is the right...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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
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,...
0
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...

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.