473,739 Members | 5,405 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 11967
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
6744
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
2057
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
5050
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
6338
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
1629
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
2229
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
5012
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
2400
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
2422
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
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8792
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
9479
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...
0
9209
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
8215
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...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3280
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.