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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem setting filter on Common Dialog control

Status
Not open for further replies.

rochelle

Programmer
May 19, 1999
64
IL
I added the MSCOMDLG.COMMONDIALOG ActiveX control to an Access97 form. It works fine except for setting the filter property. I want only the files with a .txt extension to show in the files window so I have the following two lines of code:<br>
dlgCommon.Filter = &quot;TextFiles(*.txt;*.csv;*.tab;*.asc) &quot;<br>
dlgCommon.ShowOpen<br>
<br>
which sets the filter property before invoking the control. All files are showing up. What am I doing wrong?
 
You have to follow the sytnax.<br>
Here is a snippet I keep around for it.<br>
<br>
ActiveXCtl1.DialogTitle = &quot;Find Drawing&quot;<br>
ActiveXCtl1.DefaultExt = &quot;.dwg&quot;<br>
ActiveXCtl1.Filter = &quot;Drawings (*.dwg)¦*.dwg¦All Files (*.*)¦*.*&quot;<br>
ActiveXCtl1.InitDir = &quot;G:\&quot;<br>
ActiveXCtl1.Action = 1<br>
<br>
Look closely at mine and make sure you use the Pipe symbol<br>
&quot;TextFiles(*.txt;*.csv;*.tab;*.asc)¦*.txt;*;*.csv;*.tab;*.asc&quot;<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Sorry, Doug, but that doesn't work for me. I copied the line of code straight out of your message and pasted it into my code and I still get everything.<br>
<br>
If I only want the files with the txt extension, do I still need to include all the others in the list?<br>
<br>
Are spaces significant anywhere before the pipe symbol?<br>
<br>
In your example, you set the DefaultExt property as well as the Filter property. Do you need both?<br>
<br>
Where can I find documentation on the Common Dialog control?
 
Hi rochelle, I think that there has been an error in the line which DougP gave you. He wrote :
&quot;TextFiles(*.txt;*.csv;*.tab;*.asc)|*.txt;*;*.csv;*.tab;*.asc&quot; but the correct filter would be &quot;TextFiles(*.txt;*.csv;*.tab;*.asc)¦*.txt;*.csv;*.tab;*.asc&quot;. I used it in my program and it worked fine. If you want to use only text files, you can use this filter &quot;TextFiles(*.txt)¦*.txt&quot;

Let me know if this helps.

Yc
 
Hi Rochelle, You could try this also ;o)) Good luck


' Set filters
CommonDialog1.Filter = &quot;All Files (*.*)|*.*|Text Files (*.txt)|*.txt&quot;

' Specify default filter
CommonDialog1.FilterIndex = 2

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top