Using References to User Entered Data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tyrdrannoy
    New Member
    • Jan 2009
    • 3

    #1

    Using References to User Entered Data

    Originally posted by ADezii
    This should point you in the right direction. The following code will Export the Stored Procedure named procTestExport, in an Access Project, to Microsoft Excel Format, specifically to Test Stored Procedure.xls in the C:\Test\ Directory.
    Code:
    Dim strOutputPath As String
    
    strOutputPath = "C:\Test\Test Stored Procedure.xls"
    
    DoCmd.OutputTo acStoredProcedure, "procTestExport", "MicrosoftExcel(*.xls)", strOutputPath, False, ""
    P.S. - It will not AutoStart Excel in the Export Process (the False Argument)
    is there a way to get this docmd.outputto command to pass the parameters through code, instead of having to type them in? My end users are not that SQL savvy. I would rather pass the stored procedure parameters that they have already entered into text boxes on the access form.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Any parameter that is passed a string (text within the " characters) in ADezii's code can also be passed anything that refers to a string variable. Try replacing the string parameter you want the user to enter with a reference to the control on your form (See Referring to Items on a Sub-Form).

    Welcome to Bytes!

    PS. This thread was split off from http://bytes.com/topic/access/answer...rocedure-excel

    Comment

    • tyrdrannoy
      New Member
      • Jan 2009
      • 3

      #3
      I understand how to reference the textbox values.

      I just couldn't figure out how to put the parameters into the procedure call for the excel export.

      However, I just tested it by adding the sql EXEC command before the stored procedure name:
      Code:
      docmd.OutputTo acOutputStoredProcedure,"exec sps_LoadBuilder '" & me.txtStartDate.value & "','" & me.txtEndDate.value & "'," & me.txtViewValue.value,acformatxls
      now it works. Thanks.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        I can't see that the "Exec" would be necessary, but your before and after images are not of the same thing so I can't do a matching alternative for you to try.

        I expect you're not fussed about such details anyway, and you have a working solution, so good for you and I won't worry about digging in further unless you decide you're interested in the finer details.

        Comment

        Working...