Microsoft KB Archive/304163

= How to prompt a user for a file location on an Access 2002 data access page =

Article ID: 304163

Article Last Modified on 9/27/2006

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q304163





Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

IN THIS TASK

 * SUMMARY
 * Method 1: Design-time license
 * Method 2: No license
 * Method 3: No control
 * REFERENCES



SUMMARY
This article describes how to display the Open dialog box and the SaveAs dialog box on a data access page. Because API calls are not available in scripting languages such as VBScript or JavaScript, you can use the Microsoft Common Dialog ActiveX control or write your own custom &quot;wrapper&quot; in Visual Basic around the API.

You may want to use this technique when you want to prompt the user for the file location from a data access page. You may want to do this, for example, when saving the current recordset as XML. Or you may want to do this if the page contains script to open a document in another application.

This article shows you three methods. The first method is for computers that have the design-time license for the Common Dialog ActiveX control. The second method is for computers that have the Common Dialog ActiveX control but no license. The third method is for computers that do not have the Common Dialog ActiveX control installed.

For additional information about how to start another application from a data access page, click the following article number to view the article in the Microsoft Knowledge Base:

234303 ACC2000: How to Start Another Application from a Data Access Page

For additional information about how to use the Common Dialog file Open dialog with Win32 API, click the following article number to view the article in the Microsoft Knowledge Base:

161286 How To Use a Common Dialog File Open Dialog with Win32 API

For additional information about using and distributing the Common Dialog control from a Web page, click the following article number to view the article in the Microsoft Knowledge Base:

168917 How To Set Up Internet Download for Comdlg32.ocx

Note Only developers who have a valid design-time license for the Common Dialog control may distribute the control for use in their applications or on their Web sites.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

back to the top

Method 1: Design-time license
Follow these steps to display the Common Dialog control from a data access page on a client computer that has the design-time license for the control.  Create a data access page. Open it in Design View. On the Insert menu, click ActiveX Control. Click to select the Microsoft Common Dialog Control check box, and then click OK. Change the Id property for the control to cd1. Add two text box and two command button controls to the page. Change the Id property for the text box controls to txtOpen and txtSaveAs.</li> Change the Id property for the command button controls to cmdOpen and cmdSaveAs.</li> On the Tools menu, click Macro, and then click Microsoft Script Editor.</li> Click the arrow in the Object box, and then click cmdOpen in the list. Click the arrow in the Event box, and then click onclick in the list.</li>  Modify the script as follows: <SCRIPT language=vbscript event=onclick for=cmdOpen>

</SCRIPT> </li> Click the arrow in the Object box, and then click cmdSaveAs in the list. Click the arrow in the Event box, and then click onclick in the list.</li>  Modify the script as follows: <SCRIPT language=vbscript event=onclick for=cmdSaveAs>

</SCRIPT> </li> Save and then close the page.</li></ol>

back to the top

Method 2: No license
Follow these steps to display the Common Dialog ActiveX control from a data access page on a client computer that has the control but does not have a license for the control. <ol> Follow the steps in Method 1.</li> Download the License Package Tool that is named LPKTool.exe to your local hard disk. To do this, type the following URL in your Web browser:

http://www.microsoft.com/downloads/details.aspx?displaylang=en&familyid=d2728e89-575e-42e9-a6ff-07d0021e68cc</li> Click Download.</li> In the File Download dialog box, click Save.</li> In the Save As dialog box, change the Save in box to your download files folder or to other location, click Create New Folder, type Lpk, and then press ENTER.</li> With the Lpk folder selected, click Open. Click Save to save the Lpk_tool.exe file to your new Lpk folder.</li> When the download is complete, click Close to close the Download dialog box.</li> Click Start, click Run click Browse, and then locate your Lpk folder.</li> Click Lpk_tool.exe, and then click Open.</li> <li>Click OK in the Run dialog box.</li> <li>Click Yes to agree to the license agreement. Extract the files to your Lpk folder.

Note During the extraction process, the Lpk_tool.exe files are copied to the Lpktool subfolder in your Lpk folder.</li> <li>Click OK to close the Installation Complete dialog box.

This utility creates the .lpk file. You can reference this file in the page to provide the run-time license for the Common Dialog control to client computers.</li> <li>Run the License Package Tool. Add the Microsoft Common Dialog control. Then, put the .lpk file that the tool generates in the same folder as the data access page.</li> <li>Open the page in Notepad.</li> <li> Find the OBJECT tag for cd1. Put the following OBJECT tag immediately in front of it. Make sure to replace &quot;NameOfLPKFile&quot; with the name of your .lpk file: <OBJECT CLASSID = &quot;clsid:5220cb21-c88d-11cf-b347-00aa00a28331&quot; VIEWASTEXT> <PARAM NAME=&quot;LPKPath&quot; VALUE=&quot;NameOfLPKFile.lpk&quot;> </OBJECT> </li> <li>Save and then close the page.</li></ol>

back to the top

Method 3: No control
Follow these steps to display the Common Dialog control from a data access page on a client computer that does not have the control installed. <ol> <li>Follow the steps in Method 2.</li> <li>Open the page in Notepad.</li> <li> Find the OBJECT tag for cd1. Put the CODEBASE attribute in front of the closing of the opening OBJECT tag. The OBJECT tags looks as follows: <OBJECT CLASSID = &quot;clsid:5220cb21-c88d-11cf-b347-00aa00a28331&quot; VIEWASTEXT> <PARAM NAME=&quot;LPKPath&quot; VALUE=&quot;NameOfLPKFile.lpk&quot;> </OBJECT> <OBJECT id=cd1 title=&quot;&quot; style=&quot;Z-INDEX: 1&quot; tabIndex=1 classid=CLSID:F9043C85-F6F2-101A-A3C9-08002B2F49FB VIEWASTEXT CODEBASE=&quot;http://activex.microsoft.com/controls/vb6/comdlg32.cab&quot;> <PARAM NAME=&quot;_ExtentX&quot; VALUE=&quot;847&quot;> <PARAM NAME=&quot;_ExtentY&quot; VALUE=&quot;847&quot;> <PARAM NAME=&quot;_Version&quot; VALUE=&quot;393216&quot;> <PARAM NAME=&quot;CancelError&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;Color&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;Copies&quot; VALUE=&quot;1&quot;> <PARAM NAME=&quot;DefaultExt&quot; VALUE=&quot;&quot;> <PARAM NAME=&quot;DialogTitle&quot; VALUE=&quot;&quot;> <PARAM NAME=&quot;FileName&quot; VALUE=&quot;&quot;> <PARAM NAME=&quot;Filter&quot; VALUE=&quot;&quot;> <PARAM NAME=&quot;FilterIndex&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;Flags&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;FontBold&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;FontItalic&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;FontName&quot; VALUE=&quot;&quot;> <PARAM NAME=&quot;FontSize&quot; VALUE=&quot;8&quot;> <PARAM NAME=&quot;FontStrikeThru&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;FontUnderLine&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;FromPage&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;HelpCommand&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;HelpContext&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;HelpFile&quot; VALUE=&quot;&quot;> <PARAM NAME=&quot;HelpKey&quot; VALUE=&quot;&quot;> <PARAM NAME=&quot;InitDir&quot; VALUE=&quot;&quot;> <PARAM NAME=&quot;Max&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;Min&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;MaxFileSize&quot; VALUE=&quot;260&quot;> <PARAM NAME=&quot;PrinterDefault&quot; VALUE=&quot;1&quot;> <PARAM NAME=&quot;ToPage&quot; VALUE=&quot;0&quot;> <PARAM NAME=&quot;Orientation&quot; VALUE=&quot;1&quot;> </OBJECT> </li> <li>Save and then close the page.</li></ol>

back to the top

<div class="references_section">