Avatar of ksymer
ksymerFlag for United States of America

asked on 

Need to modify ComboBox RowSource from select statement to stored procedure

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

Open in new window

Microsoft Access

Avatar of undefined
Last Comment
ksymer
ASKER CERTIFIED SOLUTION
Avatar of FrivolousSam
FrivolousSam

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of MikeToole
MikeToole
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of ksymer
ksymer
Flag of United States of America image

ASKER

None of these ideas are working.  The parameter is an integer; I also tried converting it to a string within the assignment statement.  I needed to get it done today, so I just went with the old code.  Thanks for trying!
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo