Solved

Combo Box to help find form

Posted on 2014-04-19
6
483 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

776 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