Solved

Combo Box to help find form

Posted on 2014-04-19
6
480 Views
Last Modified: 2014-04-19
I am trying to enter custom names in a combo box and have it go to that customer after it is updated. The combo box has a row source which is a query that lists all the customers as either Last, First or First Last.

I can't get the after up date to work properly. I have using the below after update. Any idea how I can get it to work?

Private Sub cbo_ContactFind_AfterUpdate()

    With Me.RecordsetClone
        .FindFirst "[CustomerID] = " & Me.cbo_ContactFind
        If .NoMatch = False Then
            Me.Bookmark = .Bookmark
        Else
             MsgBox "Contact not found!"
        End If
    End With

End Sub

Open in new window

0
Comment
Question by:cansevin
  • 2
  • 2
  • 2
6 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
can you upload a copy of your db?
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
Comment Utility
Your AfterUPdate code looks about right, so long as the [CustomerID] field is numeric.  So my guess is there is something wrong with your query.  When using this technique, my query looks like:

SELECT CustomerID, NameFull
FROM (
SELECT 1 as SortOrd, CustomerID, [NameLast] & (", " + [NameFirst]) as NameFull
FROM yourTable
UNION ALL
Select 2 as SortOrd, CustomerID, [NameFirst] & " " & [NameLast] as NameFull
) as Customers
ORDER BY Customers.SortOrd, Customers.NameFull

That way, the bound column of the combo box is the CustomerID, you can set its width to zero but refer to it as indicated in your code.
0
 

Author Comment

by:cansevin
Comment Utility
My customer ID currently isn't numberic. I am planning on trying to change that. I will change that and see if it works. Thanks!
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
looks like somebody knows your db app well :-0
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
If the customerID is not numeric, simply try:

        .FindFirst "[CustomerID] = " & chr$(34) & Me.cbo_ContactFind & chr$(34)

This will wrap the value that is in the combo box in quotes.
0
 

Author Comment

by:cansevin
Comment Utility
Changed it to a number and it works great!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

763 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

7 Experts available now in Live!

Get 1:1 Help Now