[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

create a Editable Textbox for file location?


I want to implement this feature on my report form:
There is a button on my form, when user clicks the button, it will pop up a messagebox, and there is a predefined default file location string displayed on this box, like ("C:\temp\"), the users could then edit the string on this textbox, and then they clicks ok, it will call another function to output the report to this file location (use DoCmd.OutputTo acOutputReport ... ), and the file folder is not there, program will create this folder (could DoCmd.OutputTo acOutputReport be able to create new folder based on file location parameter?).

How to create this user-interactive editable textbox and saved it to a string to be used by OutputTo command? Is there any sample code (without using Microsoft Office Library) for this kind of process? Thanks for any detailed answer.
0
heyday2004
Asked:
heyday2004
  • 5
  • 2
5 Solutions
 
JezWaltersCommented:
It's just a first stab, but is this the kind of thing you're after?

In the attached zipped database, clicking the 'Generate Report' button in the form 'frmSample' opens the form frmGenerateReport.  This form in turn allows the user to edit the folder, before outputting the report 'repSample' to the specified folder.  The folder is created if it does not exist.
Q25029939.zip
0
 
JezWaltersCommented:
You'll probably want to add a bit of error handling, and it'd be worth prompting the user before creating a new folder too, to cope with typographical errors.

Let me know if you'd like any help with either of these issues!  :-)
0
 
heyday2004Author Commented:
Thanks for the code. The only thing is I do not want to change current form design (besides adding a "export report" button). Could it be possible to use a pop up message box or pop up form to accept user input (first displaying default string) and then send it back to current form to open the reports? Thanks for any further detailed help.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JezWaltersCommented:
You could use the InputBox function instead.  Give me a mo and I'll send you another sample.
0
 
JezWaltersCommented:
This code should do what you're after:
'
' Generate Report button click handler
'
Private Sub cmdGenerateReport_Click()

    ' Declare constants
    Const REPORT_FILENAME As String = "SampleReport.rtf"  ' Report filename

    ' Declare variables
    Dim strReportFolder As String  ' Report folder

    ' Get report folder
    strReportFolder = InputBox("Report folder", "Enter report folder", "C:\Temp\")
    If Right(strReportFolder, 1) <> "\" Then
        strReportFolder = strReportFolder & "\"
    End If

    ' Create directory, if necessary
    If Dir(strReportFolder, vbDirectory) = "" Then
        MkDir strReportFolder
    End If

    ' Output Sample to specified folder
    DoCmd.OutputTo acOutputReport, "repSample", acFormatRTF, strReportFolder & REPORT_FILENAME

End Sub

Open in new window

0
 
JezWaltersCommented:
And here's a zipped database with the code, showing it all working:
Q25029939.zip
0
 
heyday2004Author Commented:
great, thanks a lot!!
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now