I need help. I've confused myself with all of the things I've tried.
I'm trying to modify the exiting Contacts template in Access 2000 to
include a search option. To the Contact Entry form I've added an
unbound text field with lable and a command button. The following code
is in the On Click event of the Command button.
Private Sub Button197_Click ()
On Error GoTo Err_Button197_C lick
Dim strWhere As String
If Not IsNull(Me.TxtSe arch) Then
strWhere = "LastName = " & Me.TxtSearch
End If
DoCmd.OpenForm "Contacts", , , strWhere
rem Err_Button197_C lick:
rem MsgBox "Error finding record: " & Error$
Rem RetVal = False
Rem Resume Next
Rem MsgBox Error$
Rem Resume Exit_Button197_ Click
Exit_Button197_ Click:
Exit Sub
End Sub
When I enter the name and click, I get a popup titled "Enter Parameter
Value" with an entry field entry field. If I enter the text in this
field, the form shows the record I'm looking for. So, it works, sort
of. Why am I getting the popup? How do I get rid of it?
Also, I'd like to have the other records available. Right now, it
just pulls up the record I'm looking for. To view the other records I
have to click the Remove Filter button on the toolbar.
While you're educating me, I don't really understand what the &
Me.TxtSearch part of the where statement does.
Thanks in advance for any help.
Dave 3 7640
You need extra quotes:
strWhere = "LastName = """ & Me.TxtSearch & """"
Explanation: You're after a string such as:
LastName = "Smith"
but this whole thing is in quotes. You can't have:
"LastName = "Smith""
because when VBA reaches the quote before Smith, it thinks the quote is
ended, and doesn't know what to do with the rest of the line. To convention
is to double-up the quotes when they are embedded, e.g.:
"This string has a ""word"" in quotes"
So, you need:
"LastName = ""Smith"""
Hence:
"LastName = """ & Me.TxtSearch & """"
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"DC" <ds*****@hotmai l.com> wrote in message
news:d2******** *************** ***@posting.goo gle.com... I need help. I've confused myself with all of the things I've tried. I'm trying to modify the exiting Contacts template in Access 2000 to include a search option. To the Contact Entry form I've added an unbound text field with lable and a command button. The following code is in the On Click event of the Command button.
Private Sub Button197_Click () On Error GoTo Err_Button197_C lick
Dim strWhere As String If Not IsNull(Me.TxtSe arch) Then strWhere = "LastName = " & Me.TxtSearch End If DoCmd.OpenForm "Contacts", , , strWhere
rem Err_Button197_C lick: rem MsgBox "Error finding record: " & Error$ Rem RetVal = False Rem Resume Next Rem MsgBox Error$ Rem Resume Exit_Button197_ Click
Exit_Button197_ Click: Exit Sub
End Sub
When I enter the name and click, I get a popup titled "Enter Parameter Value" with an entry field entry field. If I enter the text in this field, the form shows the record I'm looking for. So, it works, sort of. Why am I getting the popup? How do I get rid of it?
Also, I'd like to have the other records available. Right now, it just pulls up the record I'm looking for. To view the other records I have to click the Remove Filter button on the toolbar.
While you're educating me, I don't really understand what the & Me.TxtSearch part of the where statement does.
Thanks in advance for any help.
Dave
Thanks Allen. Any suggestions on how to get all of the records to be
available in the search results form? Right now it just opens a form
with the desired record, but I have to "remove filter" to get to the
other forms.
Dave
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message news:<41******* *************** @per-qv1-newsreader-01.iinet.net.au >... You need extra quotes: strWhere = "LastName = """ & Me.TxtSearch & """"
If you want to open the form unfiltered, just use:
DoCmd.OpenForm "Contacts"
Presumably you want to then show the first matching record:
Dim frm As Form
Set frm = Forms("Contacts ")
With frm.RecordsetCl one
.findFirst strWhere
If .NoMatch Then
MsgBox "Not found"
Else
frm.Bookmark = .Bookmark
End If
End With
Set frm = Nothing
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"DC" <ds*****@hotmai l.com> wrote in message
news:d2******** *************** ***@posting.goo gle.com... Thanks Allen. Any suggestions on how to get all of the records to be available in the search results form? Right now it just opens a form with the desired record, but I have to "remove filter" to get to the other forms.
Dave
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message
news:<41******* *************** @per-qv1-newsreader-01.iinet.net.au >... You need extra quotes: strWhere = "LastName = """ & Me.TxtSearch & """" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Les Juby |
last post by:
A year or two back I needed a search script to scan thru HTML files
on a client site. Usual sorta thing. A quick search turned up a
neat script that provided great search results. It was fast,
returned the hyperlinked page title, filename, and the body txt (30
preceding and following words) in context with the search word
highlighted. Excellent.!
See it working at: http://www.ipt.co.za
Just search for "firearm"
|
by: N. Graves |
last post by:
Hi,
I want to have a Search Dialog box that has several text box and
fields to build a search and display the results in a form. I can do
everything that I need to if I us a report but I would like to have
the search from data displayed in a form.
The structure that I have for this was take from the Asset Manger from
MS. Anyway I open a report that in turn opens up a search form that
allow me to select data. Then you continue by...
|
by: Jan |
last post by:
I am having problems trying to print a report based on a form. This
is a search form only, no data input. There is a query that the form
looks at, but then there are numerous comboxes that you can pick
information from either one or many and press a search button. See
code below for the "Case Select" that was used to make up the
comboboxes. Not a filtered list. My problem is that when I try to
print, it prints all records before the...
|
by: Christopher Koh |
last post by:
I will make a form which will search the database (just like google
interface) that will look/match for the exact name in the records of a
given fieldname. Any suggestions on how to make the code?
|
by: Steph |
last post by:
Hi.
I'm very new to MS Access and have been presented with an Access database
of contacts by my employer.
I am trying to redesign the main form of the database so that a button
entitled 'search' may be clicked on by the user and the user can then
search all records by postcode. I want to do this to prevent duplicate
data entry.
| |
by: ratnakarp |
last post by:
Hi,
I have a search text box. The user enters the value in the text box and
click on enter button. In code behind on button click i'm writing the
code to get the values from the database and binding it to a repeater
control. This repeater control has multiple text boxes and buttons. Can
you please tell me how can i do paging in this case ?
I'm posting my code below. The problem is that if i click on
"AdjustThisAd" button, it opens...
|
by: AMBLY |
last post by:
Hello ! Hope someone might be able to help me with this one. I run Access2000 on XP.
I have a form : frmONE- which contains a txt field: ctrCTN from my table/database. The values in ctrCTN are unique. Next to this field is a cmdFIND button
frmONE is open and the active window.
I want to search for values in ctrCTN, and go to the record which contains that value. I do not want to use a cmdButton with in-built Access Find procedure to...
|
by: Merlin1857 |
last post by:
How to search multiple fields using ASP
A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and having the sql statement dynamically built according to the input provided by the user. I have used the method described here hundreds of times it is quick and adaptive. I generally use a frames page for the search, in this way the search is maintained...
|
by: Fran Jakers |
last post by:
Hello all,
I'm new to all this and I could really use some help. I've searched the web but cannot find an answer.
I have an HTML form with 3 radio buttons and a search field that calls a MySQL database using JavaScript to find a product either by Product ID, Description, or Both. Originally, the 'Both' radio button was "checked" but I now want the 'Product ID' button set as the default choice (as you can see from the code below).
...
|
by: Mark |
last post by:
Hi All,
I am creating a music database for a friend and have run into a problem.
Within the ALBUM table, I wanted to store the ARTIST_ID rather than the
ARTIST_NAME. To do this, I intended to have have a command button on the
album form which would open a search form (based on the artist table). This
works as I wanted and allows me to get to one record. I then planned to have
a button on the search form which when clicked, would updated...
|
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...
| |
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,...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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...
| |
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |