?
Solved

Microsoft Access combo box help

Posted on 2016-10-17
2
Medium Priority
?
72 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
[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 Comments
 
LVL 40

Accepted Solution

by:
als315 earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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.
Suggested Courses

649 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