Solved

Microsoft Access combo box help

Posted on 2016-10-17
2
52 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 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

696 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