Solved

Add search box in Access

Posted on 2014-09-10
6
294 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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
Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

 

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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As freelancing is becoming more and more common in the tech industry, certain obstacles are proving to be a challenge to those who are used to more traditional, structured employment. This article is meant to help identify such obstacles and offer a…
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

828 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