I am trying to pass a parameter from an Access 2000 Project form over to a Stored Procedure so I can fill a list box from a table, based on the selection criteria of the passed parameter. But the parameter isn't being passed from the form for some reason. Every time the stored procedure starts to run, I get the 'pop up' message box asking for my parameter (in my example its: @varIONSNo). This same code works great when filling individual control boxes on forms, but I cannot get it to pass the parameter when trying to fill a list (or combo) box. Any help would be greatly appreciated.
My code behind my list box on enter is:
Dim cmdlstBox As ADODB.Command
Set cmdlstBox = New ADODB.Command
cmdlstBox.ActiveConnection = CurrentProject.Connection
cmdlstBox.CommandText = "FillListBox"
cmdlstBox.CommandType = adCmdStoredProc
cmdlstBox.Parameters("@varIONSNo").Value = txtIONSNo
cboEmployeeData.RowSource = "FillListBox"
Me.cboEmployeeData.Requery
End sub
And my stored procedure code is:
Alter Procedure FillListBox
@varIONSNo char(7)
As
Select employ_ID, first_name, last_name
From dbo_ZITASSOC_DATA
Where employ_ID = @varIONSNo
Order by employ_ID
/* set nocount on */
return
When I do supply the parameter manually into the pop up box, the list control fills like it should. But why am I not able to pass the parameter over to the stored procedure thru my code? I've tried many combinations of defining the parameter in Access but the results are always the same.
I've also directly bound the stored procedure to the list box in its property box but that didn't help either. Any help would be appreciated.
My code behind my list box on enter is:
Dim cmdlstBox As ADODB.Command
Set cmdlstBox = New ADODB.Command
cmdlstBox.ActiveConnection = CurrentProject.Connection
cmdlstBox.CommandText = "FillListBox"
cmdlstBox.CommandType = adCmdStoredProc
cmdlstBox.Parameters("@varIONSNo").Value = txtIONSNo
cboEmployeeData.RowSource = "FillListBox"
Me.cboEmployeeData.Requery
End sub
And my stored procedure code is:
Alter Procedure FillListBox
@varIONSNo char(7)
As
Select employ_ID, first_name, last_name
From dbo_ZITASSOC_DATA
Where employ_ID = @varIONSNo
Order by employ_ID
/* set nocount on */
return
When I do supply the parameter manually into the pop up box, the list control fills like it should. But why am I not able to pass the parameter over to the stored procedure thru my code? I've tried many combinations of defining the parameter in Access but the results are always the same.
I've also directly bound the stored procedure to the list box in its property box but that didn't help either. Any help would be appreciated.