Solved

Field on form that looks up a form

Posted on 2014-04-16
4
281 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now