473,698 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Text box on a form to search record

44 New Member
We can have an unbound text box on the form in which the person can type in the text box they want to go to retrieve information without having to use the find record button or menu option. For this we can use the After Update event to move to the desired record (please see below code). How can we hide or restrict other records to display in a columnar form as by default it shows entire record one by one? Please help or provide any alternate solution. Thank you.

This example assumes an unbound text box named "txtFindID" where the user enters the number to find:

Private Sub txtFindID_After Update()
Dim strWhere as String
If Not IsNull(Me.txtFi ndID) Then
If Me.Dirty Then 'Save first.
Me.Dirty = False
End If
strWhere = "[ID] = " & Me.txtFindID
With Me.RecordsetClo ne
.FindFirst strWhere
If .NoMatch Then
Msgbox "Not found."
Else
Me.Bookmark = .Bookmark
End If
End With
End If
End Sub

Note: If "ID" is a field of type Text, we need extra quotes:
strWhere = "[ID] = """ & Me.txtFindID & """"
Apr 4 '07 #1
3 11957
Zeeshan7
44 New Member
Please help.
Apr 5 '07 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
We can have an unbound text box on the form in which the person can type in the text box they want to go to retrieve information without having to use the find record button or menu option. For this we can use the After Update event to move to the desired record (please see below code). How can we hide or restrict other records to display in a columnar form as by default it shows entire record one by one? Please help or provide any alternate solution. Thank you.

This example assumes an unbound text box named "txtFindID" where the user enters the number to find:

Private Sub txtFindID_After Update()
Dim strWhere as String
If Not IsNull(Me.txtFi ndID) Then
If Me.Dirty Then 'Save first.
Me.Dirty = False
End If
strWhere = "[ID] = " & Me.txtFindID
With Me.RecordsetClo ne
.FindFirst strWhere
If .NoMatch Then
Msgbox "Not found."
Else
Me.Bookmark = .Bookmark
End If
End With
End If
End Sub

Note: If "ID" is a field of type Text, we need extra quotes:
strWhere = "[ID] = """ & Me.txtFindID & """"
Try something like
Expand|Select|Wrap|Line Numbers
  1. Me.Filter = strWhere
  2. Me.FilterOn = True
  3. Me.Requery
  4.  
Mary
Apr 6 '07 #3
Zeeshan7
44 New Member
Try something like
Expand|Select|Wrap|Line Numbers
  1. Me.Filter = strWhere
  2. Me.FilterOn = True
  3. Me.Requery
  4.  
Mary
Thanks for your response. Where to put this code? Secondly, what I should do with the form as it's based on a table and show all records. The code I had narrated is basically for navigation, within the form based on table. I want a text box to search and show specific record (only) in a table or query. Thank you.
Apr 6 '07 #4

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

Similar topics

7
6730
by: Dave B | last post by:
Does anyone know of a program that will read a text file and fill in a web form with the contents of that file? We need to get about 3000 records (5 fields to each record) into a database owned by another company and the only way it can be done (according to them) is to enter them one at a time into a web form. We can get the records into a comma or tab separated text file and would like to just read the file and auto insert the fields...
10
2027
by: Paul Kooistra | last post by:
I need a tool to browse text files with a size of 10-20 Mb. These files have a fixed record length of 800 bytes (CR/LF), and containt records used to create printed pages by an external company. Each line (record) contains an 2-character identifier, like 'A0' or 'C1'. The identifier identifies the record format for the line, thereby allowing different record formats to be used in a textfile. For example: An A0 record may consist of:
22
5038
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before calling up another form or report that uses some of the same data. We came up with a work around that saves the current record's ID, does a
2
6334
by: allyn44 | last post by:
Hello, I have built a serch form for users to edit records. I only want them to pull up the record they need, and I want to check for nulls. There should not be dupes becasue the underlying tables are indexed. So the user will pull up either one record or none. Here is my problem: I pass the form name through a tmpvariable and ther other search parameters through unbound fields on an unbound form--this works fine unless the form opens...
1
1621
by: =?Utf-8?B?UGF0cml4MzE3?= | last post by:
Caveat: newbie I would like to take the contents of the datagrid on my form and export it record by record to a flat text file. After some time searching, I came across two items: IO.File.WriteAllText System.IO.StreamWriter
4
2226
by: pelicanstuff | last post by:
I found some code for text-searching in forms (using an unbound text box and a command button), and adapted it to look like this: Private Sub Command83_Click() Dim strPersonRef As String Dim strSearch As String 'Check txtSearch for Null value or Nill Entry first. If IsNull(Me!) Or (Me!) = "" Or (Me!) = "Surname" Then MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
13
4984
by: Robertf987 | last post by:
Hi, Yet another thing I need help with I'm affraid. I'll first explain what I want, then I'll try to explain what I have. I'm using Microsoft Access 2000. What I want is to be able to do a search, taking it's criteria fro a text box on a form. This bit is easy, done it a jazillion times. But I want it to be an "Or" search. If I type in it "Cakes, Cheese", I don't want it to bring up results that contain cakes AND cheese, I want it to bring...
2
2398
by: Dave | last post by:
Access 2003 I have an unbound search form, which shows filtered search records in it’s sub-form. On the unbound search form I wish to place a button, which will close off the search form, and take me to my main document form, showing the selected record indicated in the initial search forms, sub-form. Using option one below, placed on any-one of the search forms, sub-
1
2417
by: angelicdevil | last post by:
i have listbox 1 which displays status , based on selection of status listbox 2 displays usernames. and based on username selected the textbox displays the email id. its working fine till displaying user names in listbox 2 based on selected of status in listbox. but its not displaying the emailid based on selection of usernames and when i click on search for users button its refreshs the page and shows the intial page also want the text box...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8901
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
8871
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
7739
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...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
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
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.