Solved

Field on form that looks up a form

Posted on 2014-04-16
4
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 48

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

688 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