/ Published in: VB.NET
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.
Expand |
Embed | Plain Text
'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: Resume Exit_btnSearch_Click End Sub
You need to login to post a comment.
