Solved

Microsoft Access combo box help

Posted on 2016-10-17
2
46 Views
Last Modified: 2016-10-17
I have a combo box that searches for a number in field orignumber.   I copied the code from another combo box and it works fine, except after it finds the data the combo box keeps the number that was searched for.   I want the number to clear after it is found.   The combo box I copied the code from clears.  Code is below for the new CBO

Private Sub cboOrigNumber_AfterUpdate()
' Comments  : Find the record for the selected SoftSlip
    ' Parameters:
    ' Created   : 09/20/04 18:00 JWV
    ' Modified  :
    '
    ' --------------------------------------------------

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    Dim rs As DAO.Recordset
    Me.Filter = ""
    Me.FilterOn = False
    Me.cmdUnfilter.Visible = False
   
    Set rs = Me.RecordsetClone
    rs.FindFirst "[OrigNumber] = '" & Me.cboOrigNumber & "'"
    If Not rs.NoMatch Then
        Me.Bookmark = rs.Bookmark
    Else
        MsgBox "Orig. Number not found!"
        DoCmd.GoToRecord acDataForm, "frmSoftSlips", acFirst
    End If
    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Sub

PROC_ERR:
    MsgBox "Error " & Err.Number & _
    " in Form_frmSoftSlips.cboOrigNumber_AfterUpdate:" & vbCrLf & Err.Description
    Resume PROC_EXIT
    'TVCodeTools ErrorHandlerEnd
End Sub
0
Comment
Question by:J.R. Sitman
2 Comments
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
ID: 41847119
You can try this sub:
Private Sub cboOrigNumber_AfterUpdate()
' Comments  : Find the record for the selected SoftSlip
    ' Parameters:
    ' Created   : 09/20/04 18:00 JWV
    ' Modified  :
    '
    ' --------------------------------------------------

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    Dim rs As DAO.Recordset
    If isnull(Me.cboOrigNumber) then exit sub

    Me.Filter = ""
    Me.FilterOn = False
    Me.cmdUnfilter.Visible = False
    
    Set rs = Me.RecordsetClone
    rs.FindFirst "[OrigNumber] = '" & Me.cboOrigNumber & "'"
    If Not rs.NoMatch Then
        Me.Bookmark = rs.Bookmark
        Me.cboOrigNumber = Null
    Else
        MsgBox "Orig. Number not found!"
        DoCmd.GoToRecord acDataForm, "frmSoftSlips", acFirst
    End If
    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Sub

PROC_ERR:
    MsgBox "Error " & Err.Number & _
    " in Form_frmSoftSlips.cboOrigNumber_AfterUpdate:" & vbCrLf & Err.Description
    Resume PROC_EXIT
    'TVCodeTools ErrorHandlerEnd
End Sub

Open in new window

Line 14 and 24 were added
0
 

Author Comment

by:J.R. Sitman
ID: 41847123
Perfect.  Thanks
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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

777 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