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

How to open a search window

Status
Not open for further replies.

Hokis

Technical User
May 21, 2007
51
US
Hi,
I need a code for a command button, that on click it opens a search window for files, so that i can select any .dbf file from my C: or whatever drive i have.
I don't know where to search for that code, I'm sorry if my question is too simple I'm very new in VB & I don't know much (anything to tell u the truth). But I'm trying to do a program, complicated one & I might need your help further more.
Thank you for your time.
Hokis
 
As you asked in the VBA forum I suggest you to have a look at the Application.FileDialog object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
what those this mean? Please bare with me as I'm very new, can you be more specific please
in the code area what will i write?
thank you
Hokis
 
In the code area you type Application.FileDialog and while the cursor is inside the FileDialog keyword you press the F1 key.
 
I did what you said & the F1 which is help, opnes, it sais Dim dlgOpen As FileDialog

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

With dlgOpen
.AllowMultiSelect = True
.Show
End With
should i do that also, i mean should i put the DIm thing in it?
so I did, but it gave me User-defined type not defined
what those this mean???
 
Hi Hokis.
I don't know much (anything to tell u the truth). But I'm trying to do a program, complicated one
If you are trying to a complicated program, and you do not know anything, then I would suggest you do NOT do a complicated program.


Start with simple, VERY simple, programs. This site is not for hand holding someone. We will gladly help anyone, but they have to do the work. Don't be concerned that you are just starting. We all had to start somewhere, knowing nothing. All of us.

So, since you do not even know what to do with a Dim, start with something easy. Use Help (F1), use google searches, look through the threads here. But start simple.

Also, please use the code tags when posting code. Look at the link to "Process TGML" below the message window.

BTW: if I use the exact code you posted:
Code:
Dim dlgOpen As FileDialog

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

With dlgOpen
    .AllowMultiSelect = True
    .Show
End With
but within an Sub of course....it works fine. So if it did NOT for you....then you did something wrong. Maybe you put the Dim in the wrong place. One of things you MUST learn is scope. Look up Understanding Scope and Visibility in Help. As you did not post full code, it hard to say, but I suspect that the problem is your Dim declaration is not in scope.

Use the macro recording function as much as you can. Not just to do things you need to do, but also to get used to looking at code. Macro recordings very often can be written much better, but you only get to do that when you know more. The only way to know more, is to DO more.

faq219-2884

Gerry
My paintings and sculpture
 
User-defined type not defined
You have to reference the Microsoft Office x.0 Object Library in the menu Tools -> References ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top