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!

Using Stored Procedure for Form. ADP

Status
Not open for further replies.

chino123

Programmer
Sep 2, 2003
5
UY
Hi,
I'm trying to open a form with the records returned from a stored procedure with parameters. I need to use different SPs with the same form. I've tried setting the RecordSource and InputParameters properties through code, but when I open the form it asks for the parameter's value. It's like the InputParameters property doesn't count. How can I do this??

Thanks in advance
 
Where and how are you setting the parameters? Show the code.
 
What I need is to open a form when I click a button on a previous form. The OnClick event on the previous form is:

Form_Busqueda.Recordset = "BusquedaApellido"
Form_Busqueda.InputParameters = "@ape =" & T_ape.Value

DoCmd.OpenForm "Busqueda"

Busqueda is the form I want to open, and BusquedaApellido is a stored procedure with parameter @ape. T_ape is a textbox with the value of the parameter. Maybe this way of doing is lame, but I'm just starting with all this.
Thanks a lot.
 
Since the Form is not active at the time you are loading the input parameters, I am not sure how that would work. Also, the stored procedure is the RecordSource.

Some suggestions.
Either pass the variables in the OpenArgs or make Public variables in a standard module. I usually make public variables and return directly or through a function with can be included in a query.
Example.
In Standard module.
Public pubApe as integer

Public Function ReturnApe() as integer
ReturnApe = pubApe
End Function

In Form that loads the variable.
pubApe = Me.yourvar

ON Open event of the Busqueda Form.

Form_Busqueda.RecordSource="dbo.BusquedaApellido"
Form_Busqueda.InputParameters = "@ape =" & ReturnApe()

Note this is RecordSource not Recordset which is the result of a select statement.


 
ON Open event of the Busqueda Form. "Me" references the Form.

Me.RecordSource="dbo.BusquedaApellido"
Me.InputParameters = "@ape =" & ReturnApe()
 
Thanks a lot guys!!
One last question: what is the meaning of "dbo" in "dbo.BusquedaApellido", and why it is needed??

Thanks again.
 
There are 3 levels to addressing a table in sql server. Usually, if you are in/connected to the database in a server you don't need the 2 higher levels. The third level is the database owner which is not needed if you are the owner or have owner rights. When you roll an application out to clients they typically won't have database owner rights, therefore, if you include that level there will not be an ownership problem. Since you are the owner the problem will not occur until other users are logged in and try to use the application.

Levels are:
Server.database.owner.table.

dbo is used to give ownership rights to other users.

You could always address any table in your database by using all 4 levels but that can be limiting. Give it a try to see how it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top