473,385 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Open a form to search for a record using a command button which prompts input box

2
I have a main form called 'Main'
I have a table called 'Instruments' (one of those rows is called TAG, contains strings)
and I have a form to display all the records of Instruments table.

I'm trying to do the following:

Have a button on Main form.
When click on it, display an input box to search for instruments TAG.
and opens the form Instrumentsform with all records of Instruments that have in their TAG what I had inputted.

I search on the internet, but I found nothing that actually works.
Dec 15 '15 #1
4 930
BHo15
143 128KB
You could use something like this for your code

Expand|Select|Wrap|Line Numbers
  1. Dim strTag as String
    strTag = InputBox("Which Tag would you like to search for?"
Then you could apply a filter to your form using strTag (see https://msdn.microsoft.com/en-us/lib.../ff194672.aspx) for a start.

Hope it goes well.
Dec 15 '15 #2
zztuf
2
Expand|Select|Wrap|Line Numbers
  1. Dim strTag As String
  2.     strTag = InputBox("TAG Name?")
  3.         Me.Filter = strTag
  4.         Me.FilterOn = True
  5.     DoCmd.OpenForm "InstrumentsForm", acNormal, , "TAG = '" & strTag & "'"
Now I just have to find out, when I type only a part of the tag, I have no results. I have to type de hole TAG exactly.

But other than that, It works like a charm.
A big thank you !!!
Dec 15 '15 #3
BHo15
143 128KB
Glad it partially worked for you.

Here are a couple of thoughts...

1) If your button is not trying to filter the existing form, but instead trying to filter a form that you are going to open, then you don't need
Expand|Select|Wrap|Line Numbers
  1.   Me.Filter = strTag
  2.   Me.FilterOn = True
The rest of it would handle that process fine.

2) If you want to filter on a partial result, you could use something like this for your Open Form statement...
Expand|Select|Wrap|Line Numbers
  1.  DoCmd.OpenForm "InstrumentsForm", acNormal, , "TAG Like '" & strTag & "*'"
I will say though, that you probably don't want to do that unless the form is a continuous form or a datasheet.
Dec 16 '15 #4
zmbd
5,501 Expert Mod 4TB
As you have discovered, the problem with this approach is that the user must have some knowledge of the "tag's" value(s).

It would be a better approach to use something like:
home > topics > microsoft access / vba > insights > example filtering on a form

and a related method:
home > topics > microsoft access / vba > insights > cascading combo/list boxes

even a simple combobox with a rowsource based on the current data set would be easier for the enduser.


Next, it sounds as if your database isn't normalized:
home > topics > microsoft access / vba > insights > database normalization and table structures

Normalization is your friend, here's a recent example of the pitfalls a non-normalized database can encounter and one possible fix: home > topics > microsoft access / vba > questions > moving between records in a form is slow in certain combo boxes>Post8
Dec 17 '15 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: dgrabuloff | last post by:
i am inputting records using a form. how do i put a command button on the form that will copy the record i just input----sometimes i have the same record that needs to be put in 3 or 4 times and i...
4
by: Steven | last post by:
Hi, Would need some thought about using a button of the existing form to search record before deleting it. Any quick help is very appreciated. Steve
4
by: sirimanna | last post by:
hi, Is any one can help me to open files in my computer(for an example: some word document)using command button... i want to open file's using my vb programme..but i can't do it...can any one...
2
by: tejavenkat | last post by:
Hi, I have one scenario i.e Download as csv is there it is a command button when we click on this the save dialog box should be open,Am using javascript how can we do this by using by javascrpt...
4
beacon
by: beacon | last post by:
Hi everybody, I have a main form, frmDeficiency, that has a tab control, deficiencyTabControl, that has a subform, fsubEpisodeDetail, on page 2 of the tab control. I also have a command button...
1
by: Palaniappan | last post by:
how to add an item into the textbox by using command button in ms access in the form from the table?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.