How to specify more than one input parameter in a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I use a stored procedure as data input for a form but need to send two
parameters (@Id1 and Id2) to the procedure. How do I format the input string?
@Id1; @Id2 do not work.

Thanks for advice!

/Leif S.
 
Two different scenarios

Unbound form
Open a recordset to your Sql database with your stored proc as the Sql
statement. For example

Set cn = New ADODB.Connection
cn.ConnectionString = strCon
cn.Open
Set rs = cn.Execute("Exec YourProc @ID1 = 1234, @Id2 = 1235")

then iterate the results populating controls on your form

Bound form
Create a passthru query with the appropriate Sql and bind your form to
the query

In the first case you have an updatable form, but you are responsible to
write any changes back to the table(s). The second scenario is going to be
a read only form.

Or have I missed the question completely?
 
Ron,

No, you have not missed the question, but I forgot to say that I am working
with a report form and that I want to pass the two parameters to the
storedprocedure behind it by using the Data.Input Parametes property for that
form. Therefore update is not relevant
 
Try this stages:

1. Create a PassThrough query , empty (named QueryName for the example)

2. run this code before openning the report, to assign the right syntax to
the query, that run the SP with the new parameters

Application.CurrentDb.QueryDefs("QueryName").SQL = "EXEC SPName " & Id1 &
"," & Id2

3. Base the report on the query created in stage1
4. Run the report

===================
Note: if the parameters are sting you need to put single quote before and
after the string

Application.CurrentDb.QueryDefs("QueryName").SQL = "EXEC SPName '" & Id1 &
"','" & Id2 & "'"
 
AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top