Go Back   Access World Forums > Microsoft Access Discussion > Macros

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-26-2013, 02:28 PM   #1
Bizzy211
Newly Registered User
 
Join Date: Jul 2013
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Bizzy211 is on a distinguished road
Search Text Field and Button

So, I've been trying to accomplish this, but to no avail. I am trying to create a Button that would search a specific table for any text string I enter in an unbounded-text field. Can this be accomplished Via a macro? Also, I do not want same entry appearing multiple times. Can anyone assist? Thanks in advance.

Bizzy211 is offline   Reply With Quote
Old 07-26-2013, 03:35 PM   #2
Alansidman
AWF VIP
 
Alansidman's Avatar
 
Join Date: Jul 2008
Location: Lake County, IL
Posts: 1,493
Thanks: 40
Thanked 244 Times in 243 Posts
Alansidman will become famous soon enough
Send a message via Skype™ to Alansidman
Re: Search Text Field and Button

When you search the specific table, are you wanting to search a specific field? Suggest you be more descriptive in your needs.
__________________
Alan


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Win 7 Office XP, 2007, 2010
Alansidman is offline   Reply With Quote
Old 07-26-2013, 03:41 PM   #3
Bizzy211
Newly Registered User
 
Join Date: Jul 2013
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Bizzy211 is on a distinguished road
Re: Search Text Field and Button

Quote:
Originally Posted by Alansidman View Post
When you search the specific table, are you wanting to search a specific field? Suggest you be more descriptive in your needs.
Thanks for your reply. No I want to search all fields withing the one form.

Bizzy211 is offline   Reply With Quote
Old 07-26-2013, 08:51 PM   #4
Bizzy211
Newly Registered User
 
Join Date: Jul 2013
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Bizzy211 is on a distinguished road
Re: Search Text Field and Button

Any help would be appreciated.
Bizzy211 is offline   Reply With Quote
Old 07-26-2013, 10:14 PM   #5
Mihail
Newly Registered User
 
Join Date: Jan 2011
Location: Romania
Posts: 2,373
Thanks: 90
Thanked 368 Times in 363 Posts
Mihail is on a distinguished road
Re: Search Text Field and Button

The Find and Replace tool will work here too. (CTRL+F)
Mihail is offline   Reply With Quote
Old 07-27-2013, 12:06 AM   #6
Bizzy211
Newly Registered User
 
Join Date: Jul 2013
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Bizzy211 is on a distinguished road
Re: Search Text Field and Button

To be more specific, is there an ApplyFilter macro I can use? Right now I am only able to search one field on a form using this command

[Notes] Like "*" & [Forms]![Search Query]![Text17] & "*"

The other fields are [Description], [Opened By], and [Assigned To].

I have not found out a way to filter through all fields to search for a text that matches what's in [Text17]

Any ideas?
Bizzy211 is offline   Reply With Quote
Old 07-27-2013, 03:21 AM   #7
Mihail
Newly Registered User
 
Join Date: Jan 2011
Location: Romania
Posts: 2,373
Thanks: 90
Thanked 368 Times in 363 Posts
Mihail is on a distinguished road
Re: Search Text Field and Button

So, you need to filter NOT to search. This are two different tasks.
Also, I'm not sure that you know the difference between macro and VBA in Access (in Excel is the same thing).

By using VBA this can be a solution:
Design a public function (in a standard module) that return a boolean value.

Code:
 
Public Function FilterRecords(N As String, D As String, OB As String, AT As String) As Boolean

Dim FindWhat As String
  FindWhat = Forms!Search_Query!Text17 & ""

  If FindWhat = "" Then
    FilterRecords = True
Exit Function
  End If

  FilterRecords = True 'Perform OR . Change to False if you wish AND

  If Instr(1,N,FindWhat) Then
Exit Function
  End If

  If Instr(1,D,FindWhat) Then
Exit Function
  End If

  If Instr(1,OB,FindWhat) Then
Exit Function
  End If

  If Instr(1,AT,FindWhat) Then
Exit Function
  End If

  FilterRecords = False 'Perform OR . Change to True if you wish AND
End Function
Base your form to a query.
In this query add one more field SelectThisRecord:FilterRecords([Notes],[Description],[OpenedBy],[AssignedTo])
In the Criteria put True.

In the form use the AfterUpdate event for the Text17 control or (better) design a button and use the Click event to requery the form.

Note please two things:
1) I have removed the spaces from the names. You should do the same in your database. If you wish to keep actual names you must adapt the code to the names with spaces. Don't ask me how to do this because I don't know.
2) This code is not tested.

Good luck !

Mihail is offline   Reply With Quote
Old 07-27-2013, 08:02 PM   #8
Bizzy211
Newly Registered User
 
Join Date: Jul 2013
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Bizzy211 is on a distinguished road
Re: Search Text Field and Button

Thanks for trying to help, but I am stuck. My knowledge is not there when it comes to Access and macros/vba/modules. I can share my database to give a better idea of what i'm trying to accomplish.
Bizzy211 is offline   Reply With Quote
Old 07-27-2013, 08:09 PM   #9
Mihail
Newly Registered User
 
Join Date: Jan 2011
Location: Romania
Posts: 2,373
Thanks: 90
Thanked 368 Times in 363 Posts
Mihail is on a distinguished road
Re: Search Text Field and Button

Do it now.
Mihail is offline   Reply With Quote
Old 07-27-2013, 08:31 PM   #10
Bizzy211
Newly Registered User
 
Join Date: Jul 2013
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Bizzy211 is on a distinguished road
Re: Search Text Field and Button

Click on the Search Tool button in case list and it will take you to my search (split) form. I want the button to search the Search Query for whatever is in the text box and display it down below. I also can't get the refresh to work correctly. Thanks for you help.

Last edited by Bizzy211; 07-27-2013 at 10:31 PM.
Bizzy211 is offline   Reply With Quote
Old 07-28-2013, 12:38 AM   #11
Mihail
Newly Registered User
 
Join Date: Jan 2011
Location: Romania
Posts: 2,373
Thanks: 90
Thanked 368 Times in 363 Posts
Mihail is on a distinguished road
Re: Search Text Field and Button

Is this what you are looking for ?

I can't find Notes field in your query
Attached Files
File Type: zip DIGS MSL (Mihail).zip (501.8 KB, 65 views)
Mihail is offline   Reply With Quote
Old 07-28-2013, 05:50 AM   #12
Bizzy211
Newly Registered User
 
Join Date: Jul 2013
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Bizzy211 is on a distinguished road
Re: Search Text Field and Button

Quote:
Originally Posted by Mihail View Post
Is this what you are looking for ?

I can't find Notes field in your query
Mihail,

Once again thank you for your help. It's almost there. The other column is Comments Not Notes. For some reason if I search, let's say Jackson - only one result shows up, but in the unfiltered query there should be several that match Jackson (Opened by, Assigned To, some job descriptions have Jackson in it.. etc). Any idea?

Lastly, In the module I notice Fasignedto - is that spelled correctly?

Once again thank you for your help.
Bizzy211 is offline   Reply With Quote
Old 07-28-2013, 07:48 AM   #13
Bizzy211
Newly Registered User
 
Join Date: Jul 2013
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Bizzy211 is on a distinguished road
Re: Search Text Field and Button

Quote:
Originally Posted by AccessBlaster View Post
I don't know if it's too late for this but it may be worth a look access-programmers.co.uk/forums/showthread.php?t=188663 here
Thanks for your reply AccessBlaster. The thing is, I want the results to be shown on the bottom of my split form. Not in a drop down box. The database Mihail assisted me on is almost there. A few issues occur, but it is really close to what I am looking for.

Bizzy211 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search button on a bound Form on a specific field mooredk Forms 5 03-21-2013 08:14 AM
Search field without button Misko Forms 3 02-13-2009 12:44 AM
Search button for specific field ritchiehicks General 5 03-03-2008 08:32 PM
[SOLVED] Search blank text field howardp Queries 1 01-31-2006 05:51 PM
Search for specific characters in a text field Newman Queries 2 05-25-2005 08:17 PM




All times are GMT -8. The time now is 01:16 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World