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
Solved

Combo Box to help find form

Posted on 2014-04-19
6
484 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 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

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.

Question has a verified solution.

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

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…
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…
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.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

808 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