Solved

Combo Box to help find form

Posted on 2014-04-19
6
486 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 48

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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 120

Expert Comment

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

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why this Update SQL not Updating! 15 57
Query Dilema in Access 2010 3 40
Want my table columns to autofit. 7 63
Access 2003, percentage between two fields 18 22
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

752 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