Alternative to getopenfilename in Ms-Access

prabha_friend

Prabhakaran Karuppaih
Local time
Today, 11:04
Joined
Mar 22, 2009
Messages
933
What is the perfect alternative for the getopenfilename in Ms-Access. Otherwise How to use that in Ms-Access.
 
GetOpenFilename Method
See AlsoApplies ToExampleSpecificsDisplays the standard Open dialog box and gets a file name from the user without actually opening any files.

expression.GetOpenFilename(FileFilter, FilterIndex, Title, ButtonText, MultiSelect)
expression Required. An expression that returns an Application object.

FileFilter Optional Variant. A string specifying file filtering criteria.

This string consists of pairs of file filter strings followed by the MS-DOS wildcard file filter specification, with each part and each pair separated by commas. Each separate pair is listed in the Files of type drop-down list box. For example, the following string specifies two file filters— text and addin: "Text Files (*.txt),*.txt,Add-In Files (*.xla),*.xla".

To use multiple MS-DOS wildcard expressions for a single file filter type, separate the wildcard expressions with semicolons; for example, "Visual Basic Files (*.bas; *.txt),*.bas;*.txt".

If omitted, this argument defaults to "All Files (*.*),*.*".

FilterIndex Optional Variant. Specifies the index numbers of the default file filtering criteria, from 1 to the number of filters specified in FileFilter. If this argument is omitted or greater than the number of filters present, the first file filter is used.

Title Optional Variant. Specifies the title of the dialog box. If this argument is omitted, the title is "Open."

ButtonText Optional Variant. Macintosh only.

MultiSelect Optional Variant. True to allow multiple file names to be selected. False to allow only one file name to be selected. The default value is False

Remarks
This method returns the selected file name or the name entered by the user. The returned name may include a path specification. If MultiSelect is True, the return value is an array of the selected file names (even if only one filename is selected). Returns False if the user cancels the dialog box.

This method may change the current drive or folder.

Example
This example displays the Open dialog box, with the file filter set to text files. If the user chooses a file name, the code displays that file name in a message box.

fileToOpen = Application _
.GetOpenFilename("Text Files (*.txt), *.txt")
If fileToOpen <> False Then
MsgBox "Open " & fileToOpen
End If

This information was obtained by typing in GetOpenFileName in the immediate window, then highlighing the word and pressing F1. Why don't you try it some time?
 
Do you mean how do you find the file name of the database? That would be:
Code:
CurrentDb.Name
to get the full path of the database from which you are running the code. If you just want the file name use something like
Code:
Mid(CurrentDb.Name,InStrRev(CurrentDb.Name,"\")+1)
 
Dcrake. I am asking about an alternative for getopenfilename in msaccess application not in Excel Application. After your answer I doubt whether getopenfilename is also in Access application too. Is it?
 
Where the hell did Excel come into this?
 
Because I pressed f2 went to the Object browser and typed 'Getopenfilename' to search about. It listed Getopenfilename 'only' under the Excel Application.
 

Users who are viewing this thread

Back
Top Bottom