Solved

Microsoft Access combo box help

Posted on 2016-10-17
2
28 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:jrsitman
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:jrsitman
ID: 41847123
Perfect.  Thanks
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now