Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Commondialog strange problem

Status
Not open for further replies.

tedsmith

Programmer
Nov 23, 2000
1,762
0
0
AU
I want the user to easily copy reports from 2 folders to a memory stick. Also be able to see the memory stick without having to browse through folders in the commondialog box.

So I set up 3 cmd buttons to open the one commondialog box only each button presets the initdir to a different folder.
"C:\Reports A", "C:\Reports B", "E:\"

This works fine until you copy the first file.

Then no matter which button you press you get the same initial directory out of the commondialog box! It sticks on the folder you last copied from unless you browse for the new folder in the box.

The InitDir statement seems to have lost it's function.

Any ideas?
 
The FileName property of the common dialog control overrides the InitDir property.

Suppose, you click button 1 and pick a file say 'C:\Reports A\RepA.txt'.

Next, you click button 2 or 3. Even if you specify a different directory using the InitDir property, the previous FileName value 'C:\Reports A\RepA.txt' forces the dialog to show 'C:\Report A' folder with 'RepA.txt' already typed in. You just have to click the Open/Save button to accept it.

To avoid this behaviour, you should reset the FileName property to vbNullString everytime, before you show the Open/Save dialog box. This will cause the dialog to consider your initial directory, which is otherwise, discarded.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top