What does this VB Code mean?

LadyDi

Registered User.
Local time
Today, 08:44
Joined
Mar 29, 2007
Messages
894
I am trying to work with a database to get it to run in 2007, but have run into code, that I don't know what it means. The line of code is Me.CmDlg.InitDir = CurrentProject.Path. I know that Me.CmDlg is the field name, but I don't know what InitDir means. I tried pressing F1, but the computer comes back and tells me it cannot find that key word. The database works in 2003, so I tried pressing F1 in my 2003 database on this word, but the help screen comes up blank.

This is code that has been placed behind a browse button, so it is intended to take you to your windows explorer.

I did not create this database, but I am trying to modify it so that I can use it in 2007.
 
The InitDir is the initial directory that the common dialog (CmDlg) will open to. So in this case it is the folder where the database file is currently residing.
 
What code do I need to have to get the folder where the database file is currently residing in 2007?
 
Since it should use the same code, why can't I get the database to run? Everytime, I try to run this database, I get an error message that states "Object doesn't support this property or method". Then, when I click on Debug, it highlights that line of code. Any ideas?
 
Since it should use the same code, why can't I get the database to run? Everytime, I try to run this database, I get an error message that states "Object doesn't support this property or method". Then, when I click on Debug, it highlights that line of code. Any ideas?
Probably more due to the fact of trying to use an activeX control which isn't available. Instead of using the Common Dialog, try replacing all of the selection stuff with the FileDialog which is available if you set a reference to Microsoft Office 12.0 Object Library (note it says OFFICE, not ACCESS)

And here's the help file - quoted (2003 because that's all I have access to at work. If you want yours, just type FileDialog in your ImmediateWindow and then hit F1:

Microsoft Access 2003 Help File said:
FileDialog Property
See AlsoApplies ToExampleSpecificsReturns a FileDialog object which represents a single instance of a file dialog box.

expression.FileDialog(dialogType)
expression Required. An expression that returns one of the objects in the Applies To list.

dialogType Required MsoFileDialogType. The type of file dialog box.

MsoFileDialogType can be one of these MsoFileDialogType constants.
msoFileDialogFilePicker
msoFileDialogFolderPicker
msoFileDialogOpen
msoFileDialogSaveAs

Example
This example displays the Save As dialog box.
Code:
Dim dlgSaveAs As FileDialog

Set dlgSaveAs = Application.FileDialog( _
    FileDialogType:=msoFileDialogSaveAs)

dlgSaveAs.Show
This example displays the Open dialog box and allows a user to select multiple files to open.
Code:
Dim dlgOpen As FileDialog

Set dlgOpen = Application.FileDialog( _
    FileDialogType:=msoFileDialogOpen)

With dlgOpen
    .AllowMultiSelect = True
    .Show
End With
 

Users who are viewing this thread

Back
Top Bottom