I have a table that I would like to be able for the users to search/filter.
I have multiple fields to search:
[DATA_OWNR]
[REC_ID]
[SERL_CD]
[DATE]
I built a form, and I would like them to be able to choose form a set of drop-downs which criteria to filter on. and then it show in the sub-form the records that match that criteria.
I initially created a select query on the table I'm searching. With Dlookups of the drop-down values for each of the relevant fields.
I can do it fine with all things being populated, but I Don't know how to make an unselected field return all values (i.e if they don't select a DATA_OWNER, it should not get filtered by that value).
any ideas on how to do this? Do I need ot do it a different way?
21 2216
Have the field return an asterisk * if it's blank.
This does not work on NULL fields.
To get around that you'll have to change the query def.
Have the field return an asterisk * if it's blank.
This does not work on NULL fields.
To get around that you'll have to change the query def.
Thanks for your help. I just have a couple of questions?
1) What do you mean by changing the query definition? To what?
2) To have it send an asterisk, do you mean, to simply change the default value of the drop-down to an asterisk?
Thanks for your help. I just have a couple of questions?
1) What do you mean by changing the query definition? To what?
2) To have it send an asterisk, do you mean, to simply change the default value of the drop-down to an asterisk?
1)Every query has a query definition. Using code you can change the query definition's .SQL property.
2) That's one way of doing it.
I set the Criteria to [Forms]![SEARCH]![ID]..... etc. for all the fields.
I set the default value to "*"
and when I run it, I get no records
When I type in a "*" in the fields, I still get no records.
As well, when I look at the query definition, there is nothing in it. What do I need to change this to? Or can you point me to some information on this?
Thanks for your help....
The criteria has to be Like [Forms]![Form Name]![Control Name]
The criteria has to be Like [Forms]![Form Name]![Control Name]
I really appreciate all your help, but I changed my criteria to what you said. Now it looks like this: -
SELECT MAST_REC_LOG.REC_ID, MAST_REC_LOG.DATA_OWNR
-
FROM MAST_REC_LOG
-
WHERE (((MAST_REC_LOG.DATA_OWNR) Like [Forms]![SEARCH_TEST]![DATA]));
Now it is not filtering any records. Did I do something else wrong.
Thanks again
Well, if DATA is = * then it won't filter anything. * returns all records.
Well - I got the * issue to work fine. Thanks so much for your help.
However, I have discovered what you meant about the Null values issue- if there is any NULL values in the entire column, it stops the filter and I get no records. So how would I fix this?
You mentioned that I would need t change the definition of the query. Currently, there is nothing in the definition - can you tell me how to fix this? O r can you point me to something that can show me how?
Thanks again for all your great help!!
Can anyone help with this?
Changing the query definition requires code. - Dim qdf As QueryDef
-
Set qdf = CurrentDb.QueryDefs("QueryName")
-
qdf.SQL = "New SQL Statement"
-
Set qdf = Nothing
-
Changing the query definition requires code. - Dim qdf As QueryDef
-
Set qdf = CurrentDb.QueryDefs("QueryName")
-
qdf.SQL = "New SQL Statement"
-
Set qdf = Nothing
-
Great. I had got to that point, but where I'm struggling is what the new SQL statements should look like to avoid the Null Problem.
Thanks again. You have been very generous in trying to help.
Great. I had got to that point, but where I'm struggling is what the new SQL statements should look like to avoid the Null Problem.
Thanks again. You have been very generous in trying to help.
You don't have to do anything to avoid the Nulls. If the user wants to return all records, meaning he leaves the textbox/combobox blank, then the SQL query will select the field but won't put any criteria on it.
One thing I forgot to mention is before assigning the new SQL you have to build the statement using code.
One thing I forgot to mention is before assigning the new SQL you have to build the statement using code.
Okay great - I think I get what I need to do. I just am not sure where I put the code. Do i put it in the Query Definition of the actual query? or do I put it in the form somewhere?
Okay great - I think I get what I need to do. I just am not sure where I put the code. Do i put it in the Query Definition of the actual query? or do I put it in the form somewhere?
What you do is build the SQL statement as a string and then store it in the existing query definition's .SQL property.
GREAT! You have been a life saver! So now I have the code down below. I just don't know how to call on it. Do I put it as an AfterUpdate... on the drop down boxes? Do I need to put a EXECUTE button? Or does it go somewhere else in the DB?
THANKS AGAIN
Okay - so I think I got there on my own. I made a search button that runs the query. When I open the query that it changes, it looks correct.
But the subform I have that shows the filtered values, on the form where they choose the search criteria, doesn't update.
I added Me.requery, but that still doesn't get me updated records. I don't know if I need to get the requery to point ot the subtable or to the underlying query...or what.
I can't find the exact syntax for that, I've tred a few things but just keep getting errors.
Is this what I need to do?
If so, what is the syntax to direct what to requery.
If not, what should I do?
Thanks again
Okay - so I think I got there on my own. I made a search button that runs the query. When I open the query that it changes, it looks correct.
But the subform I have that shows the filtered values, on the form where they choose the search criteria, doesn't update.
I added Me.requery, but that still doesn't get me updated records. I don't know if I need to get the requery to point ot the subtable or to the underlying query...or what.
I can't find the exact syntax for that, I've tred a few things but just keep getting errors.
Is this what I need to do?
If so, what is the syntax to direct what to requery.
If not, what should I do?
Thanks again
I can't remember exactly but I believe it's either: - Me.SubformControl.Requery
-
or
-
Me.SubformControl.Form.Requery
If neither works, you might have to set the record source of the subform to the query again.
Thanks for everyone's help.
I have tried adding all the following to the on_click event that updates my search criteria. - Me.SRCH___Master_Records_subform.Requery
-
'Forms![Search - Master Records].Form.Requery
-
'Me!SRCH___Master_Records_subform.Form.Requery
-
'Me!SRCH___Master_Records_subform.Requery
Currently it looks like: - Call CREATE_SQL
-
Me.SRCH___Master_Records_subform.Requery
The odd thing is that when I open the query, that the subform's record source is assigned to, the search is right.
Also, If I close the form, and then reopen it, then try to search based on a criteria, the records it returns are the ones from the previous search
example: If I choose for DATA_OWNER as TEST and click the searhc button, I won't get any records, or I will get wrong records. Then if i maually open the query - It will be only the TEST records.
Then If i close the form and reopen the form, then choose DATA_OWNER as GENIE, I get the TEST records from the previous search. I don't know why. It seems like the refresh isn't actually happening.
I don't know if I also have to requery the actual source query, or if there is a form property I need to fix, or my code is in the wrong order, or what. I'm out of ideas.
Please help. My deadline is tomorrow by noon! EST! I thought I had it working but it seems to have stopped.
Thanks for anyones help!!
I hate to bump this so soon, but I'm on a tight deadline and really hoping someone can help.....
What's the row source of the subform?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Karl Roes |
last post by:
Hi All,
I would also like some help with form filtered differences in totals.
I have a main form for the client, and a continuous subform listing
client transactions. The subform can be...
|
by: Mike O. |
last post by:
MS Access 2003 "filter by form" has drop down lists that allow the
user to select values for each field to filter by. However, once some
values are selected,the remaining dropdown lists remain the...
|
by: origin197511 |
last post by:
Hello all...
I'm having an issue with MSAccess 2000. I have a Form that holds
records of my cartridge loads for a rifle and a subform that lists all
groups that have been fired with that load. ...
|
by: KashMarsh |
last post by:
Access 2003
I need to have a user filter records on a linked, continuous form and
then I want to run various reports/queries from this recordset the user
created. I only need to see the PK...
|
by: melnhed |
last post by:
---Report the current filtered records from a Form---
Hello All,
I've seen this topic discussed before, but the solution described then
doesn't work in my particular case.
My Config: ...
|
by: Kosmos |
last post by:
Hey guys I'm a newbie and in fact I'm not even a programmer but decided to take up the task of learning access and creating a database. And I've gotten pretty far in terms of importing from excel and...
|
by: Ironr4ge |
last post by:
Hi everyone,
I am trying to open the form "Languages" with a diffrent record
source
to the "Contacts" form where I conducted the search or filter... .
I was wondering whether there was a vba...
|
by: Thelma Roslyn Lubkin |
last post by:
I have a form whose rowsource is a single table, i.e. 'Datasystem'.
I use a combobox to search for records in that table based on the
value of a single field, i.e., 'systemname'.
I use a...
|
by: jinalpatel |
last post by:
I am using following code for searching records.
'Purpose: Build up the criteria string form the non-blank search boxes, and apply to the form's Filter.
'Notes: 1. We tack " AND " on...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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: 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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |