AllExperts > Using MS Access 
Search      
Using MS Access
Volunteer
Answers to thousands of questions
 Home · More Using MS Access Questions · Answer Library  · Encyclopedia ·
More Using MS Access Answers
Question Library

Ask a question about Using MS Access
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Scottgem
Expertise
I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience
I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

 
   

You are here:  Experts > Computing/Technology > Business Software > Using MS Access > Find Record Text Box Entry

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


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.