Return to Snippet

Revision: 26179
at April 19, 2010 18:56 by cdevitt


Initial Code
'When clicking on text box, clear out the "Edit me!"
Private Sub txtSearch_GotFocus()
txtSearch.Value = ""
End Sub
Private Sub btnSearch_Click()
On Error GoTo Err_btnSearch_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmSearch"
    stLinkCriteria = "[Barcode]=" & Me![txtSearch]


    'Experts Exchange for DCount example!
    'http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_23339231.html?sfQueryTermInfo=1+access+null+stlinkcriteria
    
    If DCount("*", "tblInventoryInformation", stLinkCriteria) = 0 Then
       MsgBox ("Oops! Barcode not found!")
      txtSearch.Value = ""
    Else
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    End If


Exit_btnSearch_Click:
    Exit Sub

Err_btnSearch_Click:
    MsgBox Err.Description
    Resume Exit_btnSearch_Click
    
End Sub

Initial URL


Initial Description
I have a default value of "Edit me!" in my search box on switchboard form. Code below clears out that edit me on focus, and then clicking button obviously will search for and open up a form to the record, throwing a MsgBox error if not found.

Initial Title
text box search, open new form.

Initial Tags


Initial Language
VB.NET