Solved

Field on form that looks up a form

Posted on 2014-04-16
4
284 Views
Last Modified: 2014-04-19
I have a form that includes all my customers contact information, about 1,500 of them.

At the top of the form, I'd like to be able have a form that when you enter the Last name then First name of the client, it pulls up that record. The two table values of Last and First.

Also, as you type the last name, I'd like it to predict which client you are referring to. If two clients have the same last name and first name, I'm not sure how it would deal with.

Thanks for any info you have!
0
Comment
Question by:cansevin
  • 3
4 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 40004912
I frequently use a combo box in the form header for this purpose.

I set the query to something like:
SELECT UnionName.ContactID
, UnionName.FullName
FROM (
SELECT ContactID, [LastName] & ", " & [FirstName] as [FullName], 1 as Seq
FROM yourTable
UNION ALL
SELECT ContactID, [FirstName] & " " & [LastName] as [FullName]2 as SEQ
) as UnionName
ORDER BY UnionName.SEQ, UnionName.FullName

Open in new window

Then, set the column count = 2
The bound column = 1
and the column widths to 0, 2

Now, when you type into the combo box, whether you type:

Smith, John

or

John Smith

You will get the type ahead feature

Finally, in the AfterUpdate event of the combo, do something like:
Private Sub cbo_ContactFind_AfterUpdate

    With me.recordsetclone
        .FindFirst "[ContactID] = " & me.cbo_ContactFind
        if .nomatch = false then 
            me.bookmark = .bookmark
        else
             msgbox "Contact not found!"
        endif
    End With

End Sub

Open in new window

0
 

Author Comment

by:cansevin
ID: 40010612
Thanks fyed... I am going to try to conquer this today. Are you around to help out? There are a few things in the code I don't understand.
0
 

Author Comment

by:cansevin
ID: 40010616
In the querry select, after the is there a comma and space after the [FullName]? For the first one it is

[FullName], 1 as Seq
FROM yourTable

The 2nd one it is:
[FullName]2 as SEQ
) as UnionName
0
 

Author Closing Comment

by:cansevin
ID: 40010859
Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question