473,385 Members | 1,922 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,385 software developers and data experts.

Search two columns data in one text box

3
Expand|Select|Wrap|Line Numbers
  1. vSearchString = SearchFor.Text
this will search all field data
but I need search column1 and column2 data only
Example column1 118 column2 22
text box entering only 118 22

Expand|Select|Wrap|Line Numbers
  1. Code using:
  2.  
  3. Private Sub SearchFor_Change()
  4.  
  5. 'Create a string (text) variable
  6.     Dim vSearchString As String
  7.  
  8. 'Populate the string variable with the text entered in the Text Box SearchFor
  9.     'vSearchString = SearchFor.Text & "*"
  10.  
  11.     vSearchString = SearchFor.Text
  12.     ' vSearchString = "[PartNos] like " * " & txtBox & " * ""
  13.  
  14.     'vSearchString = Len(Me!txtName.Text & "") <> 0
  15.     'btnNext.Enabled = Len(Me!txtName.Text & "") <> 0
  16.  
  17.  
  18. 'Pass the value contained in the string variable to the hidden text box SrchText,
  19. 'that is used as the sear4ch criteria for the Query QRY_SearchAll
  20.     SrchText.Value = vSearchString
  21.  
  22. 'Requery the List Box to show the latest results for the text entered in Text Box SearchFor
  23.     Me.SearchResults.Requery
  24.  
  25.  
  26. 'Tests for a trailing space and exits the sub routine at this point
  27. 'so as to preserve the trailing space, which would be lost if focus was shifted from Text Box SearchFor
  28.     If Len(Me.SrchText) <> 0 And InStr(Len(SrchText), SrchText, " ", vbTextCompare) Then
  29.         Exit Sub
  30.     End If
  31.  
  32. 'Set the focus on the first item in the list box
  33.     Me.SearchResults = Me.SearchResults.ItemData(1)
  34.     Me.SearchResults.SetFocus
  35.  
  36. 'Requery the form to refresh the content of any unbound text box that might be feeding off the record source of  the List Box
  37.     DoCmd.Requery
  38.  
  39. 'Returns the cursor to the the end of the text in Text Box SearchFor
  40.     Me.SearchFor.SetFocus
  41.  
  42.     If Not IsNull(Len(Me.SearchFor)) Then
  43.         Me.SearchFor.SelStart = Len(Me.SearchFor)
  44.     End If
  45.  
  46.  
  47. End Sub
Mar 30 '18 #1
5 1607
twinnyfo
3,653 Expert Mod 2GB
oooppp,

Welcome to Bytes.

First, please use the Code Tags when posting code to the forum, as this is a requirement of the site. this is the [CODE/] button in your post editor. I have edited your post above.

Second, I am not sure exactly what your question is. You seem to be explaining what your code does, but have not asked a specific question. If you clarify, we would be glad to assist you.
Mar 30 '18 #2
oooppp
3
I have text box called
SrchText
vSearchString = SearchFor.Text

I have Table1 field
ACnumber
PartNos

ACnumber 122
PartNos 28
etc..

I have to search this two numbers on SrchText
at present it shows all records when enter
instead 122 28
Mar 30 '18 #3
oooppp
3
I have to enter in that search box 122 which is in one column
and 28 is another column so it will show both columns data only instead of all data

at present when I enter 122 in that search box it will show all data

My search Criteria
Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*"

hope its clear
Mar 30 '18 #4
twinnyfo
3,653 Expert Mod 2GB
Unfortunately it is still not clear.

I understand there may be a language barrier here--but I am still unclear what it is you want to do.

Try to be as specific as possible as to what you are looking for.

Thank you.
Mar 30 '18 #5
NeoPa
32,556 Expert Mod 16PB
Hi Twinny.

They want to search across two separate fields (columns) by entering the two items of numeric data into a single string control. Such items being separated by a space.

@Oooppp.
Is there a good reason you want to work this way? Under normal circumstances one would expect to enter the two field values in two separate controls on a form. To do it with a single control simply makes it more awkward to use for the operator and adds more work for you to code.

Almost everything is possible, even what you ask for here, but that doesn't mean everything is a good idea. This is a very long way from a good idea.
Mar 30 '18 #6

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

Similar topics

4
by: Richard | last post by:
Hello everyone! Is it possible to create 2 columns of text using XSL-FO and FOP (or any other XSL-FO to PDF generator)? I want the function similar to 'fo:block' but in 2 columns, so if the text...
1
by: jrs_14618 | last post by:
Hello All, This post is essentially a reply a previous post/thread here on this mailing.database.myodbc group titled: MySQL 4.0, FULL-TEXT Indexing and Search Arabic Data, Unicode I was...
1
by: christine0207 | last post by:
Hi, how to generate a fixed length data text file using Scripting.TextStream / filesystemobject.
0
by: Tequilaman | last post by:
Hi everybody! I want to search some data string of 3 to 11 characters within a hich number of files. tese files are text files with names that are not .txt but .10F etc. All are in one ffolder,...
1
by: 848lu | last post by:
hi, im trying to do a search on my Array, where a users searches on a HTML screen and then the PHP searches the array for the data under the roice entred by user.....text file data is under the php...
1
by: MiziaQ | last post by:
How can I delete a row of data from a data/text file in vb6 ? I am using an MSFlexGrid, so the user can select which row is to be deleted. Thanks in advance, MiziaQ
2
by: shane12345 | last post by:
i hav a text file anagrams.text.......and i hav a 2d array r....i want to search in the text file anagrams.txt the words present in the 2d array and if present print them....thanx....(im trying to...
1
by: Alex T | last post by:
Hello, I have a bit of a problem here: I am trying to make the search find the positions of a string in the text file. The .txt file is very large and the string comes up multiple times, so I need...
0
by: sanskruti | last post by:
Help me.. im doing project on autobizz where i need to track the order and display the dept name where it is currently present.. while executing these codes, i found an error saying : After end...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.