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!

Search Engine in a Form

Status
Not open for further replies.

oop94

Programmer
Jun 14, 2005
31
0
0
US
Hello everyone,
I would like to create a "search engine", through a macros if possible, so that the user can find the one thing among the hundreds of specs available to them in a form/subforms assembly.

My form has two subforms built into it, hence it can be really time consuming to find the one piece of information they are looking for. And I was hoping that there was a way they could just type for example "rated voltage" in the search box and they would jump to the one textbox titled "rated voltage", just like most of us do when reading a large document online - we just use "find" to get what we are looking for.

Thanks for any and all help!
 
Here's what I would try:
establish an array variable to hold the names of controls on your various forms/subforms. Iterate through the controls to populate the array. Display a search form or textbox for the user to input his search string. Use the [!]Like[/!] text comparison to locate a control that appears to match what the user typed. Use an if then else structure to determine whether or not a match exists. If a match exists, use Docmd.GotoControl to put the insertion/focus there.

Here's a rough shell:
Code:
Sub LocateControl
'*****VARIABLE DECLARATIONS
Dim ctrl As Control, arrCtrlNames(), intCountOfControls

'Redimension as a 0 based array
Redim arrCtrlNames(0)

'Iterate through controls and load their names into the array

For Each ctrl in Controls
     'Populate the array with control names
     'Not sure how to do this, but it starts like
     Redim Preserve arrCtrlNames(0 to count...)
Next ctrl

End Sub


There's still a lot to be done, but I'm sure with the shell that's started, one of the other techs can help finish.

Tom

Live once die twice; live twice die once.
 
Hello Thomas,

I am very new at VB, so I was wondering do I have to declare the variables in a specific special manner, given that they will be part of an array?
 
By surrounding the variable with parenthesis () in the declarations, it is udnerstood as an array...

Tom

Live once die twice; live twice die once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top