473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Create a search window

Ok I Idk why i cna't do this any more (seeing as I did it back in 2010, oh well.
Purpose: To create a form [Search]that contain 3 unbound text fields (Filter1, Filter2, and Filter3). When one clicks the search aka (cmdFilter) the subform [Search Results] is filtered based on the 3 text fields.
What I need help on: I need a VB code the will make the filter go from one Filter to the other then show results in the sub form.

Example:
Filter1: Smith
Filter2: John
Filter3: (Blank)


Sub form results:
Smith John A.
Smith John D.
etc....

* Form called [Search] has no record source ie unbound
* Form called [Search Results] has a record source of qrySearch

This is what I have as my code so far, but I know it isn't correct... looks off. Please help
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdFilter_Click()
  2. Dim strWhere As String
  3.  
  4.     If Not IsNull(Me.Filter1) Then
  5.         strWhere = strWhere & "([Search Results]![SNN] Like ""*" & Me.Filter1 & "*"") AND "
  6.     End If
  7.  
  8.     If Not IsNull(Me.Filter1) Then
  9.         strWhere = strWhere & "([Search Results]![Last Name] Like ""*" & Me.Filter1 & "*"") AND "
  10.     End If
  11.  
  12.     If Not IsNull(Me.Filter1) Then
  13.         strWhere = strWhere & "([Search Results]![First Name] Like ""*" & Me.Filter1 & "*"") AND "
  14.     End If
  15.     If Not IsNull(Me.Filter2) Then
  16.         strWhere = strWhere & "([Search Results]![SNN] Like ""*" & Me.Filter2 & "*"") AND "
  17.     End If
  18.  
  19.     If Not IsNull(Me.Filter2) Then
  20.         strWhere = strWhere & "([Search Results]![Last Name] Like ""*" & Me.Filter2 & "*"") AND "
  21.     End If
  22.  
  23.     If Not IsNull(Me.Filter2) Then
  24.         strWhere = strWhere & "([Search Results]![First Name] Like ""*" & Me.Filter2 & "*"")"
  25.     End If
  26.     ' And same for Filter 3
  27. End Sub
Jul 6 '12 #1

✓ answered by zmbd

SusanK4305:
You might want to review the small artical written by NeoPa
Example Filtering on a Form.
And the additional discussion about using subforms between Rabbit and myself:
Discussion: Advantages of a Subform vs. Filtering

-z

12 2302
ariful alam
185 100+
For this, I don't think you need a VBA Code.
1. First you create the search form with 3 text boxes those you called Filter1, Filter2, Filter3. And Save the form as Search.

2. Now create the Search Result select query and set the criteria for the fields which are responsible for search result. in every criteria select Search forms Filter fields in the place of # of this -> 'Like "*" & # & "*"' (without single quotation)

3. now Save the query and make a form for this query.

4. Now open the Search form in Design view and add a button on it. set the buttons command to open form and select the query result form as open form.

5. Test it.


I added a Access 2007 here as zip. you can check that.
Attached Files
File Type: zip Database.zip (65.6 KB, 138 views)
Jul 7 '12 #2
zmbd
5,501 Expert Mod 4TB
SusanK4305:
You might want to review the small artical written by NeoPa
Example Filtering on a Form.
And the additional discussion about using subforms between Rabbit and myself:
Discussion: Advantages of a Subform vs. Filtering

-z
Jul 9 '12 #3
NeoPa
32,556 Expert Mod 16PB
@Susan,

Please check out Before Posting (VBA or SQL) Code before posting again. You should probably also check the instruction threads at the top of the forum to avoid posting in a way that's against the rules. After >82 posts it's not unreasonable to expect questions that conform to the posted rules.

As for your question, I believe zmbd has given you all the help that should be required, but if you find difficulty with anything from one of the linked threads then please specify clearly your problem and someone will be happy to help you.
Jul 9 '12 #4
ariful alam ,

The prob with this is that there is nothing telling the openform cmd where to get the criteria’s.
Jul 10 '12 #5
NeoPa,

I don't mean to be disrespectful, but if I understood what all those instuctions ment I prob. would have a better idea on a simple search. I would be happy to format my question any way you (the site) would like, but I am not that advanced.
Jul 10 '12 #6
zmbd
5,501 Expert Mod 4TB
Susan,
Could you be more specific... is this in Ariful's post?
Jul 10 '12 #7
ariful alam
185 100+
@SusanK4305,

sorry, i didn't get what about u are saying. can you pls, explain.
Jul 11 '12 #8
zmbd
5,501 Expert Mod 4TB
@Susan:
I'm sure that NeoPa is only trying to help you improve your posts so that we have a common basis to help you with... much like in college or at work, reports are often required to be in a specific format. If you are having trouble understanding how to post something, ask.

Now, back to your question... even Ariful is at a loss so that's two of us in regards to #5.

I really think you should rethink your form. Having three text boxes that can take a combination of 3 different types of data in any order means that you will need some fairly complicated code - that's 10 combinations allowing for replacement and repetition. Can you really search for "John" entered three times or the same SSN entered three times?

It seems to me that either a series of cascading comboboxes or a form/subform might be easier solutions to your question. Have you had a chance to review the information in NeoPa's tutorial? There is a link there for the cascading combobox too.

-z
Jul 11 '12 #9
ariful alam,

I didn't see the attach Database before, sorry. I took a look at it and just repeated what i read in the db. It works for now, Thank you. :)
Jul 11 '12 #10
zmbd,

I know he is trying to help. I just don't understand. I will try to look at it again tonight and hope it clicks in my head.

Ariful Alam's DB will work for now. I am still looking at NeoPa's tutorial... trying to understand and see how mine works in it.

Pease note: I didn't plan on searching for John 3 time. :) I will keep looking at NeoPa's tutorial. The cascading comboboxes sound familiar.Thank y'all.
Jul 11 '12 #11
NeoPa

Ok so I think I get what to do up to 2.a (Debug \ Compile Project). It just looks like it shows me where the "error" is in my codes. I am lost, however I do get the copy/ past in B 2 and I think I get the part about Code Tag I will try to do what I can Next time, but knowing me I will prob mess it up.
Jul 11 '12 #12
NeoPa
32,556 Expert Mod 16PB
Susan,

If your code doesn't compile then you should be asking questions about how to resolve any such issues first. Trying to work with code that doesn't even compile is frustrating for everyone involved, especially yourself, as people go up blind alleys.

On the plus-side, compilation issues are generally pretty basic and easy to sort out. If you really have difficulties getting your code to compile then just say so in your question, pass as much detail as required, and someone will almost certainly be able to help you quite easily.

What doesn't make sense for anyone though, is to have multiple issues within a single question thread. It's like trying to pump water up to the basin in the bathroom, but with some of the pipework missing. A horrible mess, with all your water ending up in the walls rather than your basin.

The rules aren't meant to be complicated. I'm a little surprised that anyone who does IT work could find them so, but they are there to make life easier for all concerned. They're all just basic sense really, but sometimes it takes people with experience to write them down in a way that makes it easier for people to follow. Think of it this way. Every action you take that is not consistent with the rules is likely to make your question less likely to receive a helpful response quickly and easily. Follow the rules, as laid down, and you have the best chance of getting exactly that.

I hope this helps to clarify.
Jul 12 '12 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Steve | last post by:
C# windows I have a simple(ish) enquiry screen. on this I have a search button. I want the search window to popup as a seperate non-modal window, allow the user to search and display the...
4
by: larry | last post by:
Hi, I would like to use window search to search a word in C# CS file which create by visual studio. But I can never get that word in the cs file. for example, I used a name space:...
3
by: Jerry Camel | last post by:
I've got a web form that requires a list of user names. I'd like to have a search form that allows a person to lookup a network user name by specifying a first or last name. I can dot he code for...
2
by: Vinayaka | last post by:
Is there any way I can search a string in all the documents(not open dosument) of a project. I know I can search for a string in all the open document. Vin
3
by: Bill Smith | last post by:
In my web based application I am opening the search window using window.open(Url,UniqueName,....). Once the search is complete I am setting the value back using window.opener(...). We are...
0
by: et | last post by:
I have a program that queries a database and displays the results in the Search window (target="_search"). That was working fine until today, for some reason, the window opens but nothing is...
0
by: jshoffner | last post by:
This sounds like a really silly question but I'm can't find a solution anywhere. I use the Search window within VS.NET 2003 all the time. However, when I find a sample that is usefull I would like...
2
by: chris.royle | last post by:
I have an ASP.NET application that has a gridview control on the main window. When a user clicks on a button on the main window, a new window is opened which allows them to search for a particular...
0
by: =?Utf-8?B?TWFyY2VlcG9v?= | last post by:
I'm a newbie using Visual Studio and Vb.Net. The vbscript below opens a Windows Explorer Search Window. The Windows Explorer Search Window has fields in which the user can insert: (i) a search...
1
by: Nour469 | last post by:
Hello, I have a problem when I run search, I have fields for: name, clientID and phoneNo. When a client calls I need to find them in the database, they might give me the name and it might not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.