Hi Jeff ,
Thanks again for your help, Hope you're having had a good new year. The
query I'm looking up against that I've created looks exactly as below; the
forms I've created use exactly the same code that Ken laid out in the
previous posts (except with my field and table names in the appropriate
places so Ken's NameID has become my CANDIDATEID) - I've got the list box
working in that it displays the full names of all the candidates when
visible, only I would like any text strings entered into the text box to
scroll down that list to the relevant strings. Ideally, I'd then like to be
able to open the selected record by hitting enter.
SELECT tbl_candidate.CANDIDATEID, tbl_candidate.ContactID,
tbl_candidate.Title, tbl_candidate.[First Name], tbl_candidate.[Last Name],
tbl_candidate.[Current Employer], tbl_candidate.[Salary Requirement],
tbl_candidate.[Mobile Phone Number], tbl_candidate.[Home Phone Number],
tbl_candidate.[e-mail Address], tbl_candidate.AgencyID,
tbl_candidate.[Current Position]
FROM tbl_candidate
ORDER BY tbl_candidate.[Last Name];
Thanks very much!
Duncan
Jeff Boyce said:
Duncan
Are you saying that your query doesn't return rows for the FirstName and
LastName values you enter into the form?
What's your query look like (please post the SQL statement)?
--
Regards
Jeff Boyce
<Office/Access MVP>
Hi Jeff,
Thanks very much for getting back to me there; none of the data in the
tables or fields I've got is Lookup data, although the 'lookup default'
(I'm
not entirely sure what that is) is set to database default in my textbox
properties.
Basically I'm trying to build a quick search mechanism based on a text
search of firstname or surname into a front page of my database which
currently just acts as a gateway to other areas of my database. The form
itself currently has no dependence on other areas of the database (it just
has a graphic and a series of buttons which link to other forms through
macros) although I'm trying to search for any string a user enters in my
fields [First Name] and [Last Name] located in my query 'qry_candidate';
which is simply a query created from data entered into my table
'tbl_candidate' through 'frm_candidate'.
Thanks very much for your help!
Duncan
:
Duncan
Is there a chance one of your tables/fields involved uses the "lookup"
data
type? If so, what you see in the table and what is stored are two
different
things. This leads to problems with queries, combo boxes, list boxes,
etc.
--
Regards
Jeff Boyce
<Office/Access MVP>
Hi there,
I know it's a fair while after this post but I found Ken's response
quite
helpful for something I've been trying to incorporate into a database
of
my
own, only I seem to be having a little trouble trying to get his
solution
to
work.
I've included the Find button, which when clicked makes my textbox
visible
and below the textbox I have my listbox which becomes visible after I
hit
enter to get out of the textbox - all working well!
The issue I'm having is that when I type a first name or surname into
the
textbox (even ensuring that the match is absolutely exact), no results
are
ever returned, I'm guessing it's not a problem with the code, but
rather
something to do with the properties of either the list box or the text
box
but I'm not entirely sure.
If I set the properties of the list box to visible, I can see the full
names
of the people held in my database but I just don't seem to be able to
connect
the list box to the things I'm typing into the text box, If anyone
could
point out what I might have overlooked that would be fantastic.
I'd also ideally like to be able to double click a name in my list box
or
click a button next to the list box to open that particular person's
record
as a completed form.
Any help with this would be very much appreciated.
Thank you!
Duncan
:
This setup will let you click a command button to allow the user to
do
the
search. Clicking the button will make a textbox visible, into which
the
user
will enter a string that is the search string. The user then presses
either
Tab or Enter, and a list box will become visible that shows the
results
of
the search. The user double-clicks the name desired, and that name
is
chosen
in the combo box for the user.
I will assume that your table is named tblNames, and that the two
name
fields are called FName and LName, and that the ID field is named
NameID. I
also will assume that your initial combo box is named cboNames.
On your form, in the form header section, put a command button named
cmdFind
(make its caption "Find"). Also put a textbox (name it txtString) in
that
section, and a listbox (name it lstNames) in that section. Set the
Visible
property of both txtString and lstNames to No.
Set these properties of the lstNames list box:
-- Column Count: 2
-- Column Heads: No
-- Column Widths: 0"; 3"
-- Row Source Type: Table/Query
-- Row Source: (empty)
-- Bound Column: 1
Use this generic code for the Click event of cmdFind:
Private Sub cmdFind_Click()
Me!txtString.Visible = True
Me!txtString.SetFocus
End Sub
Use this generic code for the AfterUpdate event of txtString:
Private Sub txtString_AfterUpdate()
Dim strQuery As String
strQuery = "SELECT NameID, " & _
"FName & "" "" & LName AS FullName " & _
"FROM tblNames " & _
"WHERE FName Like ""*" & _
Me!txtString.Value & "*"" OR " & _
"LName Like ""*" & Me!txtString.Value & _
"*"" ORDER BY LName;"
Me!lstNames.RowSource = strQuery
Me!lstNames.Visible = True
End Sub
Use this generic code for the DblClick event of lstNames:
Private Sub lstNames_DblClick(Cancel As Integer)
Me!cboNames.Value = Me!lstNames.Value
Me!cboNames.SetFocus
Me!txtString.Visible = False
Me!lstNames.Visible = False
End Sub
--
Ken Snell
<MS ACCESS MVP>
Ken,
I would like to allow the user to enter a few characters and
return
all
possible matches from the partial. To me, if I am going to be
doing a
search
like this then I do not have to display the results in a combo box
unless
that is the wisest thing to do. Really, all I am trying to
accomplish
is
to
convert our call entry screen from a multiple screen slow to
navigate
app
into a one screen streamlined entry form.
An example of what I am trying to get is say a user enters in
"john" I
would
like to have the results that they get back display all firstname
matches
of
"john" and any lastname matches including "john" as all or part of
the
string. Then when they select the person they want, I would like
to
have
it
display their first and last names.