Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pareamter procedure as Recordsource of Combobox?

Status
Not open for further replies.

lameid

Programmer
Jan 31, 2001
4,208
US
While I haven't used them yet I think I understand how input parameters on forms and reports should work.

However, I have a combobox that takes a parameter and is requeried on the after update event of another combobox.
 
This is kind of odd but it worked... I created a stored procedure that takes the paramter @<field Name>
<field name> is a field on the main field.

I made the recordsource the stored procedure without specifying a parameter and it returns the correct results.

It is counterintuitive to me. The only reason I tried it is I expected an error and wanted to see what Access would do with it.

I guess it is better to be lucky than good? Naw, good is faster.
 
Major typo in that last post... first sentence talks about "a field" on the main field" instead of "on the main form". That is in addition to the type of Parameter in the original post subject <sigh>.

Just as a curiosity why does this work? Is it a proper method?
 
That worked for a bound form. Still looking for the generic right way of doing it. I definitely have unbound forms to fix as well.
 
The best I can figure is that forms default creating behind the scenes variables that get picked up and also change if you do something like import your objects to a new ADP to connect to a different server. (Upside production jet data to different server and scripted 'queries' over).

However, to get this to work all the time and consistently, I set the rowsource to an inline user defined function and concatenate the parameter in and requery.

So I write a procedure that looks something like...


Sub updateContact
Me!cboContact.Rowsource = "Select * From fnContact (" & Me!SuppID & ")"
Me!cboContact.requery
End sub

I then call updateContact on the form on current event tand the after update event for Suppid.

Depending on the application (i.e. unbound form), setting the rowsource on the forms open event is an alternative (skip the requery as the method is not available yet).
 
... I set the rowsource to an inline user defined function and concatenate the parameter in and requery."

how do you call a SP in a user defined function? "exec" ar "call" don't work.

this is the code i wrote:

CREATE FUNCTION dbo.c_sel_produs_comF_f
(@furnizor char(14), @data_doc smalldatetime, @tip char(1))
RETURNS TABLE
AS
RETURN
exec dbo.c_sel_produs_comF @furnizor, @data_doc, @tip


where dbo.c_sel_produs_comF is the SP i whant to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top