473,396 Members | 2,093 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,396 software developers and data experts.

Filter query based on the combobox/textbox

Hi friends,

I am using A2010. I have completed preparing the whole application but stuck with reports.

what I want to do:

There is 1 command button and 1 textbox/combobox(happy if works with any of the control) . When I type employeeId(which is numeric) in that control and click on command button, it should filter the query and display the result in report. It sounds easy , but not for me. I tried lots of ways to get it done. But from past 6 days stuck with this.

I am using query to fetch data in unbound combobox.

SELECT tblUserqry.[EmployeeId] FROM tblUserqry;

And below criteria in query:

Like [Forms]![Form3]![EmpID]

'EmpID is name of combobox

At last below Macro for onclick , that opens the query in datasheet .


Please note that I don't know how filter works in ms access. All types of suggestions are accepted.

I need to complete it ASAP.

Please help.

Looking forward for participations.
May 21 '15 #1
5 3693
jimatqsi
1,271 Expert 1GB
Sandy1992,
First, let me quibble with your wording. You say you are stuck on 'reports' but you then describe a problem with opening a query. Viewing query results is not viewing a report; they are different things. I think there is no report involved. Please correct me if I am wrong.

Further, you don't tell what the problem is. You have button that runs this macro. The macro opens a query. It is not clear what the name of that query is. You describe this other(?) query:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblUserqry.[EmployeeId] FROM tblUserqry; 
and then you describe a where clause
Expand|Select|Wrap|Line Numbers
  1. Like [Forms]![Form3]![EmpID]
Is that where clause part of the combobox query? That wouldn't make sense, so I think it must be part of the query the macro opens. And that looks pretty good, like it should work.

What happens when you click the button? You don't tell what result you are getting.

I think what you need to do is pretty simple. Getting help "asap" on this website should not be a problem if you will restate your problem clearly and completely. Give us more detail.

And congratulations on sticking with it. Six days fighting a program is frustrating.

Jim
May 21 '15 #2
Thanks a lot for your response. But I solved my problem :)
May 21 '15 #3
zmbd
5,501 Expert Mod 4TB
Sandy1992,
Very happy you solved your problem; however, perhaps you would be willing to share so that others may potentially benefit from your experience?
May 22 '15 #4
Yeah Sure,

I will more than happy if I can help. :)

what I did is simple.

I used combobox to fetch the data to filter my form.

In Property window, under Row Source I used
Expand|Select|Wrap|Line Numbers
  1. SELECT [AddUser].[ID], [AddUser].[EmployeeId] FROM AddUser; 
This way my combobox was displaying the data which I wanted.

Now, I used a subform to show the filtered result in it.

I created a query and on the field I really wanted to filter I used :
Expand|Select|Wrap|Line Numbers
  1. Like [Forms]![Searchbyemployeeid]![EmpID]
And lastly, on Combobox -> after update I used code :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboEmployee_AfterUpdate()
  2.  Dim Myemp As String
  3.     Myemp = "select * from Tasks where ([EmployeeId] =" & Me.cboEmployee & ")"
  4.     Me.Tasks_subform.Form.RecordSource = Myemp
  5.     Me.Tasks_subform.Requery
  6.  
  7.  
  8. End Sub
Try it out. Simple and fun :)
May 26 '15 #5
zmbd
5,501 Expert Mod 4TB
thnx you.... you might take a look at our Insights articles. There are several examples of filtering methods:
May 26 '15 #6

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

Similar topics

11
by: Matt | last post by:
Hi everyone, still pretty new to MySQL. I was wondering if there is a way to automatically filter records based on a mysql userlogin name?? I have serveral databases that I want to combine in...
5
by: RICHARD BROMBERG | last post by:
I am using MS Access 2000 and crating an application where the main table has about 90 fields. I understand how to run a where the value of a PARTICULAR field is entered into a text box. I want...
8
by: Krul | last post by:
I like to have a blank entry at top of the combobox list, so the user is able to clear the combobox. Right now, the form displays a empty entry on load, but after chosen a value once, it is not...
2
by: amith.srinivas | last post by:
Hi all, From a word macro in VBA, I am trying to create a report in access DB. The report is based on a query with a parameter. I am using Set rpt = Application.CreateReport rpt.RecordSource =...
3
by: somethings.amiss | last post by:
I searched google groups for an answer but found none that I could completely understand. I have a table. It contains fields such as 'client,date,hours,project,employee.' I have a form that...
6
by: Drum2001 | last post by:
I have a database where I need to query multiple items. Is it possible to run a query based on a textbox where the information is delimited by a comma. Example: Show me all names where...
94
by: mlcampeau | last post by:
I have a report (JobVacanciesOnly) that has a subreport (JobVacanciesOnlySR) that are based on two separate queries. MY - JobVacancyJobs SELECT Job.Code, Job.Title, Job.Grade, Grade.Minimum,...
6
gnawoncents
by: gnawoncents | last post by:
I have a form (FRMsurveyReports) with several combo boxes (e.g. Class, ClassUnique, SurveyID, etc.) which use an SQL query based on a table (TBLSurveyResponses) for their record source. The...
3
by: Becker | last post by:
I have a form "Finish" which has a record source "finish query". Criteria for the query is that they must enter an item # to view only that record at that time. I want them to be able to just type...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.