SQL Text Search.

Dec 5, 2006

Hi all,

I have done a quick search for this on the forum so I apologise if I have missed the thread that talks about this.

Basically I am interested in doing a text search on the SQL used in my Access queries.

Is this possible and how?

Thanks,

Matt.

View Replies


ADVERTISEMENT

Forms :: Search Text Box With Option Box As Criteria For Search

Mar 4, 2014

I am creating a a text box where the user enters a text then clicks an option from the option that is used as the criteria for the search e.g. Last Name, Phone , address then a command button wil run a query.

View 3 Replies View Related

Forms :: Text Box Search On ID And Populate Other Text Boxes In Same Form

Nov 12, 2013

I am trying to search on EmployeeID field and populate corresponding data like EmployeeName, EmployeePay in other text boxes in the same box .

In my Unbound Form I have three unbound Text Boxes and one Command button:

txtEmpID
txtEmpName
txtEmpPay
cmdFind

In my table EMPLOYEE i have three fields

EmpID -- Autonumber
EmpName -- Text
EmpPay -- Text

View 2 Replies View Related

General :: Search For Highlighted Text In Rich Text Box

Oct 1, 2012

Is there a way of searching a rich text box for any text which is highlighted and then deleting that text? I cannot find an answer to this anywhere..

View 2 Replies View Related

Forms :: Text Box Search To Populate Other Text Boxes?

May 10, 2015

I have a form with two text boxes and a button. I want to be able to type a value into the first Text box click the button and the second text box to be filled with the value which is stored in the Table.

The first Textbox is called barTxt, The second Textbox is called CustTxt The button is called SearchBtn and the Table is called BookInTable. I have been trying to use the code.

Code:

Private Sub SearchBtn_Click()
DoCmd.FindRecord Me.BarTxt.Value, , True, , True
CustTxt.Value = "SELECT BookInTable.Customer FROM BookInTable " & _
" WHERE Customer = """ & Nz(Me.BarTxt) & """" & _
" ORDER BY Customer"
End Sub

This however instead of displaying the Value for customer which is stored in the BookInTable. Displays The code SELECT BookInTable.Customer FROMBookInTable " & _ " WHERE Customer = """ & Nz(Me.BarTxt) & """" & _ " ORDER BY Customer"

View 6 Replies View Related

Search, Text VS Numeric.

Jun 21, 2005

I have made my Search Form that will search through my tables, some how I have a syntax error for the following: year, Section and ID, these fields are not text I use numeric values so I think the search is not working for that reason, I am not sure how can I fix it though do I have do add val() or sth.


Private Sub Command8_Click()

On Error GoTo Command8_ClickError

Dim db As Database
Dim rs As Recordset
Dim rs2 As Recordset
Dim strWhereCondition As String
Dim strSql As String

strWhereCondition = ""
strSql = "Select distinct Id From AcademicVideo Where True "

'================================'

If Not IsNull(ID) And Trim(ID) <> "" Then
strSql = strSql & " And [Id] = " & [ID]
End If

'================================'

If Not IsNull(Course) And Trim(Course) <> "" Then
If InStr(Course, "*") = 0 Then
strSql = strSql & " And [Course] = '" & [Course] & "'"
Else
strSql = strSql & " And [Course] like '" & [Course] & "'"
End If
End If

'================================'

If Not IsNull([Format]) And Trim([Format]) <> "" Then
If InStr([Format], "*") = 0 Then
strSql = strSql & " And [Format] = '" & [Format] & "'"
Else
strSql = strSql & " And [Format] like '" & [Format] & "'"
End If
End If

'================================'

If Not IsNull([Title]) And Trim([Title]) <> "" Then
If InStr([Title], "*") = 0 Then
strSql = strSql & " And [Title] = '" & [Title] & "'"
Else
strSql = strSql & " And [Title] like '" & [Title] & "'"
End If
End If

'================================'

If Not IsNull([Lecturer]) And Trim([Lecturer]) <> "" Then
If InStr([Lecturer], "*") = 0 Then
strSql = strSql & " And [Lecturer] = '" & [Lecturer] & "'"
Else
strSql = strSql & " And [Lecturer] like '" & [Lecturer] & "'"
End If
End If

'================================'

' If Not IsNull([Section]) And Trim([Section]) <> "" Then
' If InStr([Section], "*") = 0 Then
' strSql = strSql & " And [Section] = " & [Section] & "'"
' Else
' strSql = strSql & " And [Section] like " & [Section] & "'"
' End If
' End If

'================================'

If Not IsNull([Semester]) And Trim([Semester]) <> "" Then
If InStr([Semester], "*") = 0 Then
strSql = strSql & " And [Semester] = '" & [Semester] & "'"
Else
strSql = strSql & " And [Semester] like '" & [Semester] & "'"
End If
End If

'================================'

If Not IsNull([Year]) And Trim([Year]) <> "" Then
If InStr([Year], "*") = 0 Then
strSql = strSql & " And [Year] = " & [Year] & "'"
Else
strSql = strSql & " And [Year] like " & [Year] & "'"
End If
End If

'================================'


If Not IsNull([Description]) And Trim([Description]) <> "" Then
If InStr([Description], "*") = 0 Then
strSql = strSql & " And [Description] = '" & [Description] & "'"
Else
strSql = strSql & " And [Description] like '" & [Description] & "'"
End If
End If

'================================'


Set db = CurrentDb()
Set rs = CurrentDb.OpenRecordset(strSql, dbOpenSnapshot)
' If (rs2.RecordCount = Null) Then

' MsgBox "Enter A valid Record"

If (rs.RecordCount = 0) Then
MsgBox "Could Not found "

Else
strWhereCondition = "[Id] In (" & rs!ID
Do While Not rs.EOF
strWhereCondition = strWhereCondition & ", " & rs!ID
rs.MoveNext
Loop
strWhereCondition = strWhereCondition & ")"
End If
rs.Close

If strWhereCondition <> "" Then
DoCmd.OpenForm "ACVideo", acNormal, , strWhereCondition
DoCmd.Close acForm, "Search AcVideo"
End If

Exit Sub

Command8_ClickError:
MsgBox Err.Number & " " & Err.Description

Resume Next
End Sub

View 2 Replies View Related

Search For A Number Not A Text, SQL

Aug 12, 2005

I have a form with four combo box that will search for a record, as follow:

Field Name "Printer" , DataType "Text"
Field Name Month" , DataType "Text"
Field Name "Year" , DataType "Number"
Field Name "Day" , DataType "Number"

code for Find Record Button:


If Not IsNull(ID) And Trim(ID) <> "" Then
StrSQL = StrSQL & " And [Id] = " & [ID]
End If

If Not IsNull([txtname]) And Trim([txtname]) <> "" Then
If InStr([txtname], "*") = 0 Then

StrSQL = StrSQL & " And [Name] = '" & [txtname] & "'"
Else
StrSQL = StrSQL & " And [Name] like '" & [txtname] & "'"
End If
End If

'================================'


If Not IsNull([txtyear]) And Trim([txtyear]) <> "" Then

If InStr([txtyear], "*") = 0 Then

StrSQL = StrSQL & " And [Year] = '" & [txtyear] & "'"
Else
StrSQL = StrSQL & " And [Year] like '" & [txtyear] & "'"
End If

End If

'================================'


If Not IsNull([txtmonth]) And Trim([txtmonth]) <> "" Then

If InStr([txtmonth], "*") = 0 Then

StrSQL = StrSQL & " And [Month] = '" & [txtmonth] & "'"
Else
StrSQL = StrSQL & " And [Month] like '" & [txtmonth] & "'"
End If

End If

'================================'


If Not IsNull([txtday]) And Trim([txtday]) <> "" Then

If InStr([txtday], "*") = 0 Then
StrSQL = StrSQL & " And [Day] = '" & [txtday] & "'"
Else
StrSQL = StrSQL & " And [Day] like '" & [txtday] & "'"
End If

End If

'================================'


This is only a part of the code, I have a problem with year and day since they are numbers not text I was told that i cant use this line:

StrSQL = StrSQL & " And [Month] like '" & [txtmonth] & "'"

I was told that there is no need to use "like", am not really sure how to do it, any help will be appreciated.

Thanks.

View 2 Replies View Related

How To Search Subform With Text Box

Mar 5, 2013

how to search subform with textbox and button in form

View 2 Replies View Related

Search List Box With Text Box

Jun 2, 2010

I have a list box pulling information from a table. It include fields for last name, first name, primary number, secondary number, and id; of course with different names. I display first and last name, but the rest are hidden. What would be ideal is if I could begin typing someones first or last name in the text box and it would just start either narrowing the list, like in itunes, or would start skipping down the list and would be highlighted. For example. If I was searching the number for walmart, i could go to the text box and type "wal" and it might highlight "wallace, james"; and if I added and "m" to that, it would skip down to "walmart".

I would settle for autofill and click a search command button when I'm done, and it takes me to that entry in the list box. I copied some code off the internet. Don't know if it'll work, but here is what I got.

Private Sub txtSearch_AfterUpdate()
Dim srchstrng As String
srchstrng = Me.txtSearch.Value
SQL = " SELECT Phone.last_name, Phone.first_name FROM Phone_"
WHERE (((Phone.last_name) Like '*" & srchstrng & "*'));"
Form.RecordSource = SQL
DoCmd.RunCommand acCmdRefreshPage
End Sub

It says there is a problem with the where clause.

View 6 Replies View Related

Search Blank Text Field

Jan 31, 2006

I can alway make a query like the following one to table and return the records:

SELECT * FROM people WHERE PhoneNo<>"";

However, it returns nothing while it should return a lot of records if I make a query like this:

SELECT * FROM people WHERE PhoneNo="";

The PhoneNo file is of text type. As I know, this field is added after the MS database has been put into use for some time.

Can anyone please explain this to me?

Thanks,

View 1 Replies View Related

Partial Text Search Facility

Feb 28, 2008

I’m trying to provide the users of my database with a text search facility.

The database deals with documents, and I’d like the user to be able to search by title of document, with partial text matches. E.g. a title might be ‘Health and safety at work act’ - so searching by Health and/or safety gives this document as a result.

The table is called ‘tblDocTitle’ with the field ‘Title’ containing just that.

Ideally the search facility would be some sort of text box in which the text, and then a button to initiate that search.

Hope you can help

View 4 Replies View Related

Modules & VBA :: Search List Box With Text Box

Apr 15, 2014

i have got the bellow code that filters a listbox which is based on a query, from a textbox. The code works fine and it Filters, but if i put in too many characters that do not exsit in the data( so it cant display any results) i get an error saying Run time error 2105 - You cant go to the Specified record? how i can catch this error so it does nothing apart from display a blank listbox with no error?

code:

Private Sub txtSearch_Change()
Me.lstShowSupplier.Requery
DoCmd.Requery
Me.txtSearch.SetFocus
If Not IsNull(Len(Me.txtSearch)) Then
Me.txtSearch.SelStart = Len(Me.txtSearch)
End If
End Sub

View 3 Replies View Related

Modules & VBA :: Text Search Box - On Key Down Nested IF

May 24, 2014

Ok I'm building a Text Search box that "Live Filters" the results in a ListBox control on the same form.

After typing in a value (Say, for Customer First Name like "Steven") I want the code to do the following:

1. If there is no value in the listbox that matches when the user presses the enter key....open the New Customer form - THIS WORKS

2. If there is a single value in the list, then open this record in the customer form when the user presses the Enter key Receiving a Syntax Missing Operator error on this line:

Code:
DoCmd.OpenForm "frmContacts", , , "[ID]=" & Me.ListCustomers.Column(0)

However, I use this exact code on a button elsewhere in my project (NOT within an IF Function) and it works perfectly fine!

Code:
Private Sub txtSearch_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If Me.ListCustomers.ListCount = 0 Then
CmdNewCustomer_Click

[Code] .....

View 2 Replies View Related

Search For Specific Characters In A Text Field

May 25, 2005

I have a table with a large text field in it, among other fields.
What I am trying to do, in a query, is to show only the characters that are between brackets "[" and "]" for that field. And, if there is more than one pair of brackets, show only what lies between the last pair of brackets.

What I've tried so far is use InStr() functions to find these brackets and then use a Mid() function to show the enclosed text. But, it doesn't work well and it gives me a very complex query! In fact, I don't think it is a good idea to even use these functions in my query. That would probably slow it down a lot.

Can someone show me a function that I could use to do what I'm looking for? I need function names that could help me make better searches for more informations.

Thank you!

View 2 Replies View Related

Use Form & Query To Search For Text & Number

May 19, 2006

Hello,

I have a form with a listbox on, the listbox uses a query to populate it, which returns a list of client names. The idea is, when I enter the clients name in a text box, the list is narrowed, through use of the query.

This works fine, and always has - very pleased with it, the problem comes when I decide I want to be able to search on the account number as well - which it always throws errors about.

I am using the following query (posting the sql, hope that is OK)

SELECT tblSafeKeep_Clients.SafeKeepClientID, tblSafeKeep_Clients.Title, tblSafeKeep_Clients.Initials, tblSafeKeep_Clients.Surname, Format(tblSafeKeep_Clients.DesignationNumber,"000000") AS Expr1
FROM tblSafeKeep_Clients
WHERE (((tblSafeKeep_Clients.Surname) Like "*" & [Forms]![frmSafeKeep_SelectClient]![txtSearchText] & "*")) OR (((tblSafeKeep_Clients.DesignationNumber)=[Forms]![frmSafeKeep_SelectClient]![txtSearchText]));


The problem is because I am only using ONE text box, but the surname is (obviously) text, and the account number is (obviously!) a number. SO - it throws a wobbler about it being too complex to evaluate when I try to search for a surname, trying to search for an account number works just fine.

Any ideas how to get around this?

View 3 Replies View Related

Modules & VBA :: Search Button With Text Field

Jun 19, 2014

I'm fairly new to Access / VBA and have been trying relentlessly to get a text box / search button on my Access form to pull up a specific record. Although the null command produces the correct error msgBox, it does not show any record if I enter a correct primary key term.

Search button = SearchButton1
Search criteria = SearchText1
Primary key field = UniqueAEVRef

Code:
Private Sub SearchButton1_Click()
If IsNull(SearchField1) = False Then
Me.Recordset.FindFirst "[UniqueAEVRef]='" & SearchField1 & "'"
Me!SearchField1 = Null
If Me.Recordset.NoMatch Then
MsgBox "No record found", vbOKOnly + vbInformation,
Me!SearchField1 = Null
End If
End If
End Sub

View 5 Replies View Related

Queries :: Search For Certain Text In A Field And Return Value

Jan 1, 2015

I am trying to search for specific text in a field and returns its value. For instance some of string includes Sub, L2L, Temp, Model, or MTM and I would like a query to return these values if found.

View 2 Replies View Related

Forms :: Text Box To Search Through All Fields In Tables

Aug 12, 2014

I need making a search function for a form. I have a form with details about telephone counselors and want to be able to place a text box at the top that allows me to search through all the fields in the tables that the form relates to or displays.

View 13 Replies View Related

Search Through All Access Queries For Text In SQL String

Feb 2, 2012

I need to find a way to search through all of the queries in my Access 2007 database to change the names of more than a few variables. There are close to 900 queries I need to search through many of which may use the variables as criteria, so if I miss even 1 instance I might screw myself completely.

I found this post and it tells me exactly what I need to do. Only problem is the post was written in 2002, and I've followed the below instructions only to have it not work.

As a contractor working predominantly on databases I haven't developed, it can be a daunting task trying to find references to tables, fields or functions within a list of several hundred queries.

The following code is attached to a command button on a simple form listing all queries in the database. The record source for the form is

SELECT DateCreate, Name FROM MSysobjects WHERE Type=5 ORDER BY DateCreate DESC

There is a text box where the user enters the text to search for. The code builds a table containing the SQL string of every query, then searches for the required text, and displays those that match.

Your form also needs a procedure the set the record source back to the default.

There are off-the-shelf applications such as Speed Ferret which perform this sort of function, however some employers are too cheap to purchase them!

Code:
sub cmdFilter_Click()
Dim db As Database
Dim rs As Recordset
Dim rsFilter As Recordset
Dim tdf As TableDef
Dim strSQL As String
Dim strQdf As String

On Error GoTo ErrorHandler

[Code] ....

View 11 Replies View Related

Replace New Lines After Search String With Corresponding Text With A Tab

Mar 25, 2014

I need to loop through text files and replace the new lines following the from, to, copy and subject fields with tabs and place the associated text on the same line as the from, to, copy and subject fields.

I start out with this. See below.

From:

ABC COrp@abc.com
To:
XYZ Inc.@xyz.com
Copy:

Me@abc.com; Myself@abc.com; Irene@xyz.com

Subject:

NOthing much

I need it to be like this.

From:ABC COrp@abc.com

To:XYZ Inc.@xyz.com
Copy:Me@abc.com; Myself@abc.com; Irene@xyz.com
Subject:NOthing much

How can I do this in access?

View 14 Replies View Related

Search Multiple Text Fields In A Table From A Form

Aug 8, 2006

Please bare with me as I am an Absolute Access VB code novice . I have a Form in my Access DB and I found the Following code on this site and placed it behind my search button :

Private Sub SearchButton_Click()
DoCmd.OpenReport "All users", acViewPreview, , "[AUP].[First Name] = '" & Me.[Text34] & "'"

End Sub

The Search works great but only searches on the 1 Field "First Name" . How would I expand the VB code to include another 2 fields within my table . ( the other 2 fields I want to serach appear on the Form ) .

View 4 Replies View Related

Forms :: Using Single Search Button For Multiple Text Box

Feb 22, 2014

I am creating search boxes within that searches customer by lastname, phone number, address and suburb. Will I be able to use one search button for all of them or do they have to be individual buttons?

View 4 Replies View Related

Forms :: Search / Update / Auto-populate From Text Box

Oct 16, 2013

I have a simple login form (really just an audit tracking form) that requires the person to enter in their email address and select an office number from a combo box. Essentially, upon first entry, they will put in their email address and select an office number. When they return to the database and put in their email, it will automatically populate the combo box.

I need the text box (EmailLogin) to do 3 things: update an EmailLogin field on a table called EmailLogin (which I already have it set to do), search a field called EMail in a table called Staff, and update a combo box (cboOfficeNumb) below it if it matches an entry from EMail on the Staff table with the field OfficeNumb.

I have the cboOfficeNumb updating the OfficeNumb field on both EmailLogin and Staff tables.I am unsure of how to use a Query to perform the search and use DLookup for the update of the cboOfficeNumb.I am okay with modifying the tables to remove OfficeNumb from the EmailLogin table, as it is really just tertiary.

View 14 Replies View Related

Multiple Text Search On One Column To Filter Records?

Mar 6, 2013

I have a column that has a bunch of keywords they are separated by comma... so for each row of that column it will have a few different keywords example: lake superior, river, mountain, lake wollongong

I know its a bit of a nono with databases to have columns with comma separated text.. well so i read somewhere anyway but the document i have been handed to work has hundreds of rows in this column with up to 14 keyword entries.

I have a form that searches through Item's names based on 2 keyword boxes.

Here's the criteria in my query:

Is Null Or Like "*" & [Forms]![frmItemView]![SearchPhrase1] & "*" And Like "*" & [Forms]![frmItemView]![SearchPhrase2] & "*"

This will show all records when both keywords are blank, and filter records using the 2 keywords otherwise.

I have a form with two text boxes and have set the correct values as outlined in Evans post. I then have the query set to run via a button. I run it but it will only give back records for the entry i have put in the 1st text box. This would work well for me otherwise... mine is like this:

Is NULL or Like "*" & [Forms]![Searchtable]![Key1] & "*" And Like "*" & [Forms]![Searchtable]![Key2] & "*"

Searchtable being my search form
key1 being my first text box entry
key2 being my second text box entry

View 1 Replies View Related

Modules & VBA :: How To Execute Free Text Search In Linked Documents

Apr 10, 2014

I have a table which lists all documents that refer to a certain entity. the table contains the file names and paths. I would like the user to be able to search for text inside these documents.Can I use Windows Search for that by using code? Is there any other way?

View 6 Replies View Related

Forms :: Hide / Show Text Boxes Based On Search

Aug 2, 2014

I have a form (employee info) that requires the user to do a search to find the employee before then editing anything that needs to be edited.

I have a search box that will find the relevant record without any problem, however what I am looking to do is hide text boxes on the form and have them appear only once the search has found the matching record.

If no matching record is found, I would then like a message box that states 'No matching employee, would you like to add an employee' and when the user clicks OK, it then reveals the same hidden text boxes and sets focus to the first one of the bunch.

Now, I have used the 'me.textboxname.visible = True (or False) elsewhere, however, I am not sure how to trigger that after a search.

I assume I am looking at an If statement, but I am not sure how to construct it, hence turning to the experts.

Code:
Private Sub txtEmployeeSearch_AfterUpdate()
If txtEmployee = DLookup("EmployeeNumber", "tblEmployeeInfo") Then
Me.txtboxname.Visible = True
Me.txtboxname2.Visible = True
DoCmd.GoToControl "txtboxname"
Else
MsgBox "Employee Not Found", vbYesNo
<<<<<<<<<<<<<<<<<<<<<<
End If
End Sub

I know that there is a massive gap where I have put <<<<<<<<<<<<<<<< - but I am stumped as to what to put in there?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved