| |
You are here: Experts > Computing/Technology > Business Software > Using MS Access > Find Record Text Box Entry
Expert: Scottgem - 11/6/2009
Question QUESTION: I have access 2007 and I would like to creat text box entry on the switchboard that would allow someone to enter a document number, hit enter, and have the form open up to that specific record.
ANSWER: Frankly I wouldn't do it that way, but you can by using the After Update event of the textbox. Use the Code Builder to add this line of code:
DoCmd.OpenForm "formname",,,"[DocNumber] = " & Me.DocNumber
Supply your own formname and name of the document number field and controlname.
But the way I would do it, is to use the combobox wizard and create a "search combo" (3rd option) in the header of the form. The advantage of doing it that way is the user can find the record, then still navigate among the records or go back and find another record without having to go back to the switchboard.
Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA
---------- FOLLOW-UP ----------
QUESTION: Scott, I am now geting a compile error. Methohd or data member not found. FY2010 is the Form name and DOC# is the field within the form I want search. See below.
Option Compare Database
Private Sub Text2_Click()
DoCmd.OpenForm "fy2010", , , "[Doc#] = " & Me.DOC#
End Sub
Answer First, you shouldn't use the Click event of the Text box, I said to use the After Update event. Second, if the name of the textbox is Text2, then that's probably why you got the error. I suspect the full error (which you should always provide) was Member Not Found. Because you don't have a control named DOC#. Either change the name of the control or use Me.Text2 in the code.
Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA
Add to this Answer Ask a Question
|
|