473,614 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search Facility

I would like to search a form with many fields on it, with out using
the search facility through access. Througth a drop down list if
possible.... How would I go about this? How could I also create this
from a top bar menu option too...?

Elaine

May 9 '07 #1
3 2202
ARC
Hi Elaine,

The following code will cycle through all controls on a form...I actually go
deeper with this routine, and cycle through the controls on up to 2 subforms
deep, so if you need that to, let me know. The code below actually formats
all date fields to the user's preference, but what you're really intersted
in is if the control type is a textbox, then you would add code for your
search, otherwise, you could ignore the other fields:
For Each ctl In f.Controls
If ctl.ControlType = acTextBox Then
If f(ctl.Name).For mat = "Short Date" Then
If nomask = 0 Then f(ctl.Name).Inp utMask = f2!DateInputMas k
f(ctl.Name).For mat = f2!DateStyle
End If
'If f(ctl.Name).fon tname <DefFont Then
' f(ctl.Name).fon tname = DefFont
'End If
ElseIf ctl.ControlType = acLabel Or ctl.ControlType = acCommandButton
Then
If TransYN = -1 And f(ctl.Name).Vis ible = -1 Then
CurrCap = f(ctl.Name).Cap tion
criteria = "lblPhrase = " & Chr(34) & CurrCap & Chr(34)
f(ctl.Name).Cap tion = CheckTranslateD b(rs, criteria, CurrCap)
End If
'If f(ctl.Name).fon tname <DefFont Then
' f(ctl.Name).fon tname = DefFont
'End If
ElseIf ctl.ControlType = acSubform Then
If f(ctl.Name).Sou rceObject = "" Then
GoTo Contin
end if
' i took out the rest of this code that cycled through the controls
on any subforms
end if
Next Ctrl
May 9 '07 #2
On May 9, 9:48 am, Elainie <Elaine.Macint. ..@bsc.wales.nh s.ukwrote:
I would like to search a form with many fields on it, with out using
the search facility through access. Througth a drop down list if
possible.... How would I go about this? How could I also create this
from a top bar menu option too...?

Elaine
ARC's solution looks pretty complex: I think you can do what you want
by adding two .ComboBox es and a button to your form.

..cbxFields.Row SourceType = 'Field List'
..cbxFields.Row Source = 'myTable' (the table you want to search)

On open, this box will be populated with a list of the fields in the
myTable base table.

..cbxValues.Row SourceType = 'Table/Query'
..cbxValues.Row Source = "SELECT " & Me.cbxFields & " FROM myTable WHERE
" & Me.cbxFields & " IS NOT NULL GROUP BY " & Me.cbxFields

Add an event to cbxFields_After Update:

Private Sub cbxFields_After Update
Me.cbxValues.Re query
End Sub

So after you select which field to search, the second ComboBox is
populated with a list of all of the unique values in the field chosen
in cbxFields

As you type in the Value combo box, the selection will narrow. Add a
button to click when you have selected the value you want to search
for. In that button's _OnClick

Private Sub btnFilter_OnCli ck()
Me.Filter = Me.cbxFields & " = " & Me.cbxValues
Me.FilterOn = True
End Sub
This will filter the rows returned from the base table to those
matching the value in the filter setting. This is simplified somewhat
- you will have to add buttons to clear the filter and reset the
comboboxes, and you will also have to alter the filter syntax slightly
to accomodate text, numeric and date datatypes (damn it!). This should
be a start.

Ron, King of Chi
May 9 '07 #3
ARC
I agree that it's overkill, maybe. That code is made to cylcle through all
controls on any form. So if this is for a specific form only, then King's
post would definetely be easier...
"King Ron" <Ki************ ***@covad.netwr ote in message
news:11******** **************@ e65g2000hsc.goo glegroups.com.. .
On May 9, 9:48 am, Elainie <Elaine.Macint. ..@bsc.wales.nh s.ukwrote:
>I would like to search a form with many fields on it, with out using
the search facility through access. Througth a drop down list if
possible.... How would I go about this? How could I also create this
from a top bar menu option too...?

Elaine

ARC's solution looks pretty complex: I think you can do what you want
by adding two .ComboBox es and a button to your form.

.cbxFields.RowS ourceType = 'Field List'
.cbxFields.RowS ource = 'myTable' (the table you want to search)

On open, this box will be populated with a list of the fields in the
myTable base table.

.cbxValues.RowS ourceType = 'Table/Query'
.cbxValues.RowS ource = "SELECT " & Me.cbxFields & " FROM myTable WHERE
" & Me.cbxFields & " IS NOT NULL GROUP BY " & Me.cbxFields

Add an event to cbxFields_After Update:

Private Sub cbxFields_After Update
Me.cbxValues.Re query
End Sub

So after you select which field to search, the second ComboBox is
populated with a list of all of the unique values in the field chosen
in cbxFields

As you type in the Value combo box, the selection will narrow. Add a
button to click when you have selected the value you want to search
for. In that button's _OnClick

Private Sub btnFilter_OnCli ck()
Me.Filter = Me.cbxFields & " = " & Me.cbxValues
Me.FilterOn = True
End Sub
This will filter the rows returned from the base table to those
matching the value in the filter setting. This is simplified somewhat
- you will have to add buttons to clear the filter and reset the
comboboxes, and you will also have to alter the filter syntax slightly
to accomodate text, numeric and date datatypes (damn it!). This should
be a start.

Ron, King of Chi


May 9 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1754
by: bissatch | last post by:
Hi, I would like to add a search engine facility onto my website. This way, if anybody uses it to search my site they will be presented with a page of results where their search query matched that contained within the page's text. I have done something like this for news articles but these are articles that are stored within a database so a simple SQL query would do. For this it would actually need to search the HTML page (ie.
4
1553
by: Speaking Clock | last post by:
Hi, I have recently taken over the responsibility for a medium sized .org website that has been written entirely in .asp. Because there is a highly restrictive proprietary Content Management System in place, I have only limited control over the site - I can't even create a new page without asking the webhost to do it for me (for which there is an hourly charge). I have asked about changing to a CMS that will give me more control, but...
5
1510
by: Deryck | last post by:
Hi, I am working on an e-commerce site. It uses a CMS. One requirement is to have a static off-line version so that the company's sales reps can visit customers and take orders on a laptop without having to go online (I'm told that the rep's customers don't always appreciate being asked for a phone line to be tied up and that sometimes they operate in areas of poor cellular coverage). The reps upload their orders when they reach a phone...
4
2260
by: KiwiBrian | last post by:
What do you recommend for an application I can host on a web site that can provide a site search facility? I thought I read that Google had a new aplication for this but I can't find any reference to it now. Thanks Brian Tozer
2
1792
by: GMK | last post by:
HI ALL I'M COMING FROM A FOX PRO BACKGROUND WHERE I COULD IN A VERY EASY WAY CREATE A SEACH FACILITY BY PRESSING N F1 AND ANOTHER WINDOW WILL DIRECTLY APPEAR WHICH WOULD LET THE USER TO SEARCH FRO A SPECIFIC DATAVALUE AND INSERT IT IN A TEXTBOX IN THE ORIGINAL FORM. I WOULD LIKE TO CREATE A SIMILAR FACILITY IN ASP.NET I DON'T WANT A KEYPRESS FUNCTION I COULD CREATE A BUTTON ON THE SCREEN BUT I WANT TO CREATE A POPUP WINDOW WHERE I COULD...
2
1710
by: Alan Silver | last post by:
Hello, I am in the planning stages of a new ASP.NET web site, and would like to know if it's possible to add a search facility to it. The site will be a mixture of static pages and ones generated from database queries. Ideally I would like something that will search the pages generated by following links as that way it will index the whole site, not just the static bits. I looked through Google, but couldn't find a decent answer to...
6
2630
by: jej1216 | last post by:
I am trying to put together a PHP search page in which the user can select none, one, two, or three fields to search, and then the results php will build the SQL with dynamic where caluses to reflect the fields chosen. The first page, where they select the search fields and submit: <?php $db = mysql_connect("localhost", "root", "yeahright"); if (!$db) { die('Could not connect:'.mysql_error);
3
1363
by: tonydraper | last post by:
I have built a website and for some reason the search facility has stoppped working? When I carry out a job search the page that it redirects to comes up with this. Source Error: Line 107: protected string formatSalary(object Salary, object jobType) Line 108: { Line 109: int iSalary = Convert.ToInt32(Salary);
0
8198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8591
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8294
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8444
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7115
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5549
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4138
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2575
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.