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!

ADODC , Stored Proc w/ Parameters...Ahh! 1

Status
Not open for further replies.

JHerr

Programmer
May 25, 2001
42
US
OK heres the deal:
I have a form with a datarepeater with a custom control and an ADODC control with a SP as the rec src. My problem right now is i can't figure out how to send the parameters to the SP using the ADODC. i can do it with a coded ado connection or with a dataenvironment, but these raise other problems (for instance, i can't get the datarepeater to work with the coded ado connection).
So... ado datacontrol... stored procedures...parameters... Any help is greatly appreciated!!
 
I had the same problem. I think you do not need ADO or other chinese food. I found this and it works (provided Acees is installed on the running PC). Hope you can use it too:

first step: I made a new query in Access to select the records I need (doesn't matter how you name it)
second step: I made a report in Access based on this query - I called this report rptReport (must be the same name in the example code below)
third step: I use this code

some variable explanation for this examples:
- rptReport = name of report in Access
- TABLE = table in database also used in query
- FIELD = field parameter you want to pass to the report, in this case an Integer
- Combobox = combobox on the form from wich the user can select to obtain the appropriate report

'example 1. in order to have the report printed immediately without preview:
Dim Acc As Access.Application
Set Acc = New Access.Application
Acc.OpenCurrentDatabase "C:\Path Database"
Acc.DoCmd.OpenReport "rptReport", acViewNormal, , "TABLE.FIELD=" & CInt(ComboBox.Text)
Acc.Visible = False 'not sure this is really needed
Set Acc = New Access.Application

'example 2. in order to have a preview of the report (you can then click the print icon to have it printed):
Dim Acc As Access.Application
Set Acc = New Access.Application
Acc.OpenCurrentDatabase "C:\Path Database"
Acc.DoCmd.OpenReport "rptReport", acPreview, , "TABLE.FIELD=" & CInt(ComboBox.Text)
Acc.Visible = true
Set Acc = New Access.Application

Important: in your query design, put no Criteria value in the TABLE.FIELD, you will be passing the paramter value using the Acc.DoCmd.OpenReport statement, and the report will pass your parameter further upstream to the query in order to make the reight selection

good luck
vincent
acady@yucom.be
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top