Advertisement

07.16.2008 at 06:05PM PDT, ID: 23571814
[x]
Attachment Details

Need to modify ComboBox RowSource from select statement to stored procedure

Asked by ksymer in Access Coding/Macros, Microsoft ADP, Access Forms

Tags: Microsoft, Access, 2003, Microsoft Office Access Project (adp), VBA, 6.5

I have a legacy form function that populates a combo box using a hard-coded select statement.  It is noted below as Existing.

I want to simplify maintenance by referencing a stored procedure instead.  

My approach is not working and I would appreciate any pointers on the correct method and/or syntax.  The proposed code does not produce errors; the combo box is simply empty.  Please note that I need to keep the solution in this function.  Thanks!Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
''''''Existing''''''
 
Private Sub Form_Current()
On Error Resume Next
Me.Parent.Controls("txtActivityId") = [activity_id]
Me.Parent.Controls("subfrm_share_activity_steps").Form.Controls("step_key").RowSource = "select b.step_key, b.short_name, b.step_order from dbo.tbl_activity_step_type b where b.active = 1 and activity_key = " & Me.Controls("activity_key").Value & " order by step_order"
End Sub
 
''''''Proposed''''''
 
Private Sub Form_Current()
On Error Resume Next
Me.Parent.Controls("txtActivityId") = [activity_id]
Dim cmb As ComboBox
Dim sql As String
cmb = Me.Parent.Controls("subfrm_share_activity_steps").Form.Controls("step_key")
sql = "exec dbo.sp_get_activity_steps_available " & Me.Controls("activity_key").Value
cmb.RowSource = sql
End Sub
[+][-]07.17.2008 at 12:51AM PDT, ID: 22023167

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, Microsoft ADP, Access Forms
Tags: Microsoft, Access, 2003, Microsoft Office Access Project (adp), VBA, 6.5
Sign Up Now!
Solution Provided By: FrivolousSam
Participating Experts: 2
Solution Grade: B
 
 
[+][-]07.17.2008 at 01:55AM PDT, ID: 22023467

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.17.2008 at 06:02PM PDT, ID: 22031810

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628