Solved

Add search box in Access

Posted on 2014-09-10
6
280 Views
Last Modified: 2014-09-11
Hello,

A real Access novice here!
I have a access database that I need to enter the primary key and have the fields populate related to that entry.  This works now with the search box that frames the screen but I want to have the search box in the body of the form.  Is this possible?
0
Comment
Question by:1212pro
  • 3
  • 2
6 Comments
 
LVL 9

Expert Comment

by:macarrillo1
ID: 40315066
I think what you are asking for is a subform.

The Subform would be related via a Foriegn key.

So you would drop a Subform into your main form and map the relationship keys.

Am I understanding your question?
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40315076
yes, it is possible.
open from in design view
add a textbox, name it txtSearch

place this codes in the afterupdate event of the textbox

private sub txtsearch_afterupdate()
if me.txtsearch & ""="" then exit sub
with me.recordsetclone
    .findfirst "[primaryKey_FieldName] =" & me.txtsearch
    if not .nomatch then
         me.bookmark=.bookmark
        else
         msgbox "Record not found"
    end if
end with

end sub
0
 

Author Comment

by:1212pro
ID: 40315438
Experts.docx

OK I think I did this right Rey.  Here are some screen shots of what was done.  I cannot put any text in the textbox, is shows #Name?  Maybe I missed something
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:1212pro
ID: 40315451
macarrillo1  Please see the screen shots to see if that answers your question.  Any other suggestions would be helpfull

Thanks
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 40315592
change "primaryKey_FieldName" with the actual name of the field that holds the primary key

the textbox "txtsearch" must be UNBOUND (meaning- Control source property must be blank) (see the DATA tab on the property window of the textbox.)
0
 

Author Closing Comment

by:1212pro
ID: 40316740
Nice simple solution.  Works great
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

To stay competitive, modern businesses must adapt and stay innovative, and this is increasingly only possible by working with outside talent. Managers and executives have understood the power of outsourcing for quite some time, but traditional clien…
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now