I have a query name ICISquery, table field names are ARE of Employee, Date of ARE, Item Description and Remarks.
The table field ARE of Employee is a name of employee.
ICISquery has a 10000 records. I have a form name (home) in this form has a combolist and its row source are the name of employees. I have another form name (list) in datasheet view. when i click one of the employee in combolist, the list form will show up and its recordsource is ICISquery. But i want ICISquery will show only the records of employee i have clicked. For example, i click Juan Reynulfo, the list form will show up and contains only the records of Juan Reynulfo. Is this the work of filter in a query? If so, how can i apply this filter in query when you call it?
Hi again, eneyardi.
Fortunately for you I know what you wish from this thread: How to shorten codes that using if, else and end if?
Because from actual thread I can't understand :).
So, one way to do this is to make a new module (or use an existing one.
In this module delare a PUBLIC variable. Say strName and create a PUBLIC function (say fGetName)
Something like this: - Option Explicit
-
-
Public strName As String
-
-
Public Function fGetName() As String
-
fGetName = strName
-
End Function
In your query, in the field ARE criteria row, write: fGetName().
Close the query and the module (of course save the changes).
Now, go to your combo box (in design view) and, under On Click event write this code: - Private Sub ComboName_Click()
-
strName = ComboName
-
End Sub
That must be all to do.
From now to ever, when you select a new name from your combobox this name will be stored in strName variable. So, when you run the query (or something else like a form or a report based on this query) the query itself will apply (from the criteria row) the function fGetName which will return the value stored in strName (the name you preview selected in your combo box).
Hope you understand the technique and how it work even my English is not very good.
11 15055
Hi again, eneyardi.
Fortunately for you I know what you wish from this thread: How to shorten codes that using if, else and end if?
Because from actual thread I can't understand :).
So, one way to do this is to make a new module (or use an existing one.
In this module delare a PUBLIC variable. Say strName and create a PUBLIC function (say fGetName)
Something like this: - Option Explicit
-
-
Public strName As String
-
-
Public Function fGetName() As String
-
fGetName = strName
-
End Function
In your query, in the field ARE criteria row, write: fGetName().
Close the query and the module (of course save the changes).
Now, go to your combo box (in design view) and, under On Click event write this code: - Private Sub ComboName_Click()
-
strName = ComboName
-
End Sub
That must be all to do.
From now to ever, when you select a new name from your combobox this name will be stored in strName variable. So, when you run the query (or something else like a form or a report based on this query) the query itself will apply (from the criteria row) the function fGetName which will return the value stored in strName (the name you preview selected in your combo box).
Hope you understand the technique and how it work even my English is not very good.
That is certainly one way of doing, and under some circumstances can be very usefull.
I will just for good measure mention another way of doing it:
Presume you have your report set up intially to show all records of all employees. You can also choose to open the report and apply the filter at the same time.
This could be done like so, presuming you have a simple combobox (comboSelectName) listing just the name: - Dim strName as string
-
strName=Me.ComboSelectName
-
-
Dim strFilter as string
-
strFilter="EmployeeName='" & strName & "'"
-
-
Docmd.OpenReport "NameOfReport",acViewPreview,,strFilter
Now this will open the report in preview mode, with the filter applied. Its a very usefull feature. The same feature can also be used for forms btw.
That's exactly what i'm looking for. thank you guys! I'm excited to apply that on my simple program, I'll give you the update later.
- Dim strName As String
-
strName = Me.Combo238
-
-
Dim strFilter As String
-
strFilter = "EmployeeName='" & strName & "'"
-
-
DoCmd.OpenForm "list", acNormal, strFilter
Smiley It shows all the records strfilter not working.
The Recordsource of form name (list) is QueryofMasterlist the field EmployeeName = Combo238 rowsource
Mihail i followed your instructions but is not working, i don't know what is my fault. The recordsource became blank
Remove all information from your database, ZIP it and attache it to your next post. Before removing information be sure you make a copy of your database (for safe).
I can think about some reasons that my code make an empty record source:
First can be that you don't use PUBLIC variable and/or function. I don't know if you use Option Explicit statement in yours modules.
The second reason can be that your Combo238 has the first column hidden.
I assume that Combo238 is a bound control. If it is not then we are in war with the wind mills.
I have no idea why Smiley's code give you ALL the records ?!?!
Have you an explication, Smiley ? (you know: I try to learn a little bit SQL. Thank you !)
NeoPa 32,556
Expert Mod 16PB
Please review [code] Tags Must be Used. After over a hundred posts you shouldn't still be posting this nonsense so that other people have to go around after you tidying up.
I will simply delete any of your posts I see in future if they contain untagged code.
I'm sorry neopa, I'll do that next time.
Mihail thanks alot it works now! I only forgot to save. hehehe.
So, one query and five lines of code.
Is now enough short for you ? :)
Glad to help you.
Yup, it's a big help for me. Because we're using the program in LAN base, interaction speed improves alot. Thank you!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: MaryD |
last post by:
Is there any way to use the enter key - or a function key - as the
Apply Filter when a form is opened in FilterByForm mode? I can see
the value of function keys and the enter key when the form is...
|
by: Iyhamid |
last post by:
Hi
I am looking for codes to filter and apply filter to my data base using access
|
by: mattscho |
last post by:
Hi All, Trying to create a set of 3 buttons in a form that have the same effect as the "Filter by Form", "Apply Filter" and "Remove Filter" Buttons on the access toolbar. Help would be muchly...
|
by: mattscho |
last post by:
Re: Filter By From, Apply Filter, Remove Filter Buttons in a Form.
--------------------------------------------------------------------------------
Hi All, Trying to create a set of 3 buttons in...
|
by: Nhoung Ar |
last post by:
Can anybody out there help me please on apply filter in MS Access. I have a form that create from the query, which contain field chidid (text field), in the form footer, I add the button to open...
|
by: Gari |
last post by:
Hello,
I am trying to build a filter query with some AND and OR.
I have three text boxes and 5 check boxes. The checkboxes are linked via code to other textboxes for the purpose of the query.
...
|
by: Supermansteel |
last post by:
I am trying to run a Apply filter for everytime someone opens Form_CC it will only show the Test (Test_ID) they are working on. This seems to be the closest I have gotten to filtering it correctly,...
|
by: eHaak |
last post by:
A couple years ago, I built a database in MS Access 2003. I built the form using macros in some of the command buttons, and now I’m trying to eliminate the macros and just use visual basic code. ...
|
by: dbdb |
last post by:
hi guys
need your suggestion
how can i apply filter for my date variable data type
i have a form name transaction
and i have a text box on it named : start and finish
i need to apply...
|
by: dbdb |
last post by:
Hi,
i create a chart in ms access based on my query, then i want my chart when is it open is only show value based on my criteria.
i'll try to used it in the properties apply filter using the...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |