Solved

Combo Box to help find form

Posted on 2014-04-19
6
485 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
[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
  • 2
  • 2
  • 2
6 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40010817
can you upload a copy of your db?
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 40010823
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
ID: 40010825
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40010829
looks like somebody knows your db app well :-0
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40010847
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
ID: 40010858
Changed it to a number and it works great!
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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

735 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