Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
giovi2002
Starting Member
46 Posts |
Posted - 2005-07-22 : 18:48:47
|
Workbench : access adp / sql serverscript : Ado Goal: Pass a value from a form (1) to a stored procedure (2) and retrieve and show the recordset within the application (3)Status: 1 and 2 work with the written code, for number 3 'receive the recordset' I had to use a stupid workaround by having my SP to fill a table, after table is being filled my ado code will open a view based on this table. It would be more efficient to have my sp only to perform a parameterized query. Can you extend my ado code?I've used Dim rstKoppeltabel As ADODB.Recordset but don't know how to fill the recordset and display the results within the access adpPrivate Sub SYSLIJNNUMMER_DblClick(Cancel As Integer)On Error GoTo Err_Form_DblClickDim myado As ADODB.CommandDim rec As SingleDim StrBronrec As Variant 'parameter 1Dim StrReprec As Variant 'parameter 2Dim nmbSyslijnnummer As Variant 'parameter 3Dim stDocName As StringDim rstKoppeltabel As ADODB.Recordset 'recordset declarationSet myado = New ADODB.Commandmyado.ActiveConnection = CurrentProject.Connectionmyado.CommandType = adCmdStoredProcmyado.CommandText = "dbo.Ap_Rapportagegegevens_Bronrecords"StrBronrec = "%"StrReprec = "%"nmbSyslijnnummer = Me.SYSLIJNNUMMERmyado.Parameters.Append myado.CreateParameter("Bronrecord", adVariant, adParamInput, 12, StrBronrec)myado.Parameters.Append myado.CreateParameter("Reprecord", adVariant, adParamInput, 12, StrReprec)myado.Parameters.Append myado.CreateParameter("Syslijnnummer", adVariant, adParamInput, 12, nmbSyslijnnummer)myado.ExecuteDoCmd.OpenView "dbo.Vw_Koppeltabel_inzien", acViewPreview, acReadOnly 'this part opens the view and should be replaced by fill the recordset 'and display the resultsExit_Form_DblClick: Exit SubErr_Form_DblClick: MsgBox Err.Description Resume Exit_Form_DblClickEnd Sub |
|
SMerrill
Posting Yak Master
206 Posts |
Posted - 2005-08-09 : 13:48:19
|
It seems you have already used ...Dim rstKoppeltabel As ADODB.Recordset 'recordset declaration ...so you just need to replace your ...myado.execute ... with ...set rstKoppelTabel = myado.Execute ... This results in a filled recordset.~ Shaun MerrillSeattle, WA |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2005-08-09 : 19:06:07
|
Is the input parameter and recordset display on the same form? If so, you can do the following:-Insert your subform and make it's recordsource equal to the name of your stored procedure-Name your parameter controls the same as the stored procedure input parameter (e.g. if your stored proc has a varchar parameter called @SearchCriteria, then you name your input text box SearchCriteria.)This is done in much the same way as Access has traditionally done things with its queries. It can be a pain in the butt to use sometimes (what with naming conventions and the like), but it can be a quick and easy way around your problem.I'm not sure that this is a documented feature of Access ADP's, though. I found it out more by accident....HTH,Tim |
|
|
|
|
|
|
|