Link to home
Start Free TrialLog in
Avatar of Ptsa
Ptsa

asked on

How Can I avoid form design when passing parameters to a MS Access ade?

I have an adp where I commonly use the following code in order to pass variables for some diagrams that I need

 DoCmd.OpenForm stdocname, acDesign, , stlinkcriteria      
 Forms("idx_1c").RecordSource = "exec idx_1c " & CStr(Me.XthFrom.Value) & "," & CStr(Me.XthTo.Value)
         
 DoCmd.Save acForm, "idx_1c"
 DoCmd.Close acForm, "idx_1c"
 DoCmd.OpenForm stdocname, acFormPivotChart, , stlinkcriteria

When I convert the adp into an ade the previous technique fails and gives an error message since it requires "design" view of the form which is not allowed in ade projects.
Is there any workaround in order for me to pass the parameters to the form?

Thank you
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image


  Set the forms recordsource in the OnOpen event of the form when it opens.

  You can pass the params in the OpenArgs property, or through a global variable.

JimD.
Avatar of Ptsa
Ptsa

ASKER

Thank you very much for the answer.
Unfortunately when I change the form's recordsource in the OnOpen or OnLoad event the PivotChart shows nothing...

<<Unfortunately when I change the form's recordsource in the OnOpen or OnLoad event the PivotChart shows nothing...>>

  Hum, can't think of why that would be.  OnOpen should work.  OnLoad is too late.  The recordsource has already been read and the forms recordsource opened.

  Let me double check...may have something to do with the pivot chart, which I've never used.

JimD.
 
SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ptsa

ASKER

Thank you once again.

1st choice: Could work, but unfortunately Microsoft things differently
              http://support.microsoft.com/kb/298046 and I wouldn't like to use OWC10 or OWC11...

2nd choice: Does not give me any results neither.

 Dim rst As ADODB.Recordset
Set cmd = New ADODB.Command


        With cmd
            .CommandText = "idx_1c"
            .CommandType = adCmdStoredProc
            .ActiveConnection = CurrentProject.Connection
            .Parameters.Append .CreateParameter("@VarXTHFrom", adBigInt, adParamInput, _
             , CStr(Me.XthFrom.Value))
            .Parameters.Append .CreateParameter("@VarXTHTo", adBigInt, adParamInput, _
             , CStr(Me.XthTo.Value))
                       
           
            Set rst = .Execute
            Set Form_Idx_1c.Recordset = rst
docmd.openform  "idx_1c",acFormPivotChart
End with
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ptsa

ASKER

Case successfully closed!