Hi -
In Access 2000, I have a form I want to filter, but I can't get the syntax right in the code.
Form: [JOB filtered]
Subform: [P PRODUCT]
Control on [P PRODUCT]: txtStart
Nested Subform on [P PRODUCT]: [Survey Form]
Control on [Survey Form]: txtSDate
Both controls are dates.
I want to filter the form "On Open" to show only records in which txtStart is not null and txtSDate is null.
I've figured out how to reference the controls:
Forms![JOB filtered]![P PRODUCT].Form![txtStart]
and
Forms![JOB filtered]![P PRODUCT].Form![Survey Form].Form![txtSDate]
... but I can't figure out the null/not null part.
How would I write this?
Angi
9 3066
Hi -
In Access 2000, I have a form I want to filter, but I can't get the syntax right in the code.
Form: [JOB filtered]
Subform: [P PRODUCT]
Control on [P PRODUCT]: txtStart
Nested Subform on [P PRODUCT]: [Survey Form]
Control on [Survey Form]: txtSDate
Both controls are dates.
I want to filter the form "On Open" to show only records in which txtStart is not null and txtSDate is null.
I've figured out how to reference the controls:
Forms![JOB filtered]![P PRODUCT].Form![txtStart]
and
Forms![JOB filtered]![P PRODUCT].Form![Survey Form].Form![txtSDate]
... but I can't figure out the null/not null part.
How would I write this?
Angi
How about this: -
SELECT * FROM YourTable
-
WHERE Not IsNull(Forms![JOB filtered]![P PRODUCT].Form![txtStart]) And IsNull(Forms![JOB filtered]![P PRODUCT].Form![Survey Form].Form![txtSDate])
How about this: -
SELECT * FROM YourTable
-
WHERE Not IsNull(Forms![JOB filtered]![P PRODUCT].Form![txtStart]) And IsNull(Forms![JOB filtered]![P PRODUCT].Form![Survey Form].Form![txtSDate])
I'm getting an error on line 1, highlighting the * and saying "Compile Error. Expected: Case"
Also, this form is run from a query. Should I be inserting the query name instead of the table in line 1? (Incidentally, that didn't make a difference regarding the error message.)
I'm getting an error on line 1, highlighting the * and saying "Compile Error. Expected: Case"
Also, this form is run from a query. Should I be inserting the query name instead of the table in line 1? (Incidentally, that didn't make a difference regarding the error message.)
1. If the data source for this query is another query and not a table, then by all means, use the query name.
2. Did you type this query in a continuous fashion with no line breaks and no extra spaces etc.? Please post your query so that I can look at it.
Thanks.
1. If the data source for this query is another query and not a table, then by all means, use the query name.
2. Did you type this query in a continuous fashion with no line breaks and no extra spaces etc.? Please post your query so that I can look at it.
Thanks.
Oh... You're suggesting I create a query for the form instead of using VB code to filter it. I was trying to put your SQL code in the VB window. Hah...No wonder it didn't work.
So, the syntax in my first message for identifying the controls on the subforms was in VB. Should the same syntax work in SQL? I'm thinking no -- it doesn't appear to work. It's asking me to enter a parameter value for Forms!JOB filtered!P
Oh... You're suggesting I create a query for the form instead of using VB code to filter it. I was trying to put your SQL code in the VB window. Hah...No wonder it didn't work.
So, the syntax in my first message for identifying the controls on the subforms was in VB. Should the same syntax work in SQL? I'm thinking no -- it doesn't appear to work. It's asking me to enter a parameter value for Forms!JOB filtered!P
It should also work in the vb code window, provided you have a semi-colon at the end of the sql string. When you use the Access sql view, Access will add the semi-colon for you. In the vb window, you have to add the semi-colon because the vb editor will not do it for you.
As for the parameters, you are probably being asked to declare it. IF you are in query design view, go to the Access command menu and select query>parameters and when the dialog box comes up, fill inhe particulars. If you are the code window, the parameters clause must precede your select statement. The syntax is as follows (fill in P;s datatype):
PARAMETERS Forms!JOB filtered!P P's datatype;
It should also work in the vb code window, provided you have a semi-colon at the end of the sql string. When you use the Access sql view, Access will add the semi-colon for you. In the vb window, you have to add the semi-colon because the vb editor will not do it for you.
As for the parameters, you are probably being asked to declare it. IF you are in query design view, go to the Access command menu and select query>parameters and when the dialog box comes up, fill inhe particulars. If you are the code window, the parameters clause must precede your select statement. The syntax is as follows (fill in P;s datatype):
PARAMETERS Forms!JOB filtered!P P's datatype;
The problem is that there is no "P". It's the subform [P Product]. But Access isn't recognizing the whole name, and it's not recognizing that it's a form. If it's looking for a datatype, I can't really give it one, since it isn't data.
The problem is that there is no "P". It's the subform [P Product]. But Access isn't recognizing the whole name, and it's not recognizing that it's a form. If it's looking for a datatype, I can't really give it one, since it isn't data.
Ok, that is your problem, you are providing an invalid parameter....probably due to incorrect syntax.....which is why I asked you to post your current sql statement. In absence of your sql statement, I can only guess......your syntax problem could be anything from a missing parenthesis to an extra space.....please post your current sql statement so that I can see it. Thanks.
sierra7 446
Recognized Expert Contributor
Hi
It seems to me that you are trying to filter a 'Main' form, using criteria set in the 'Sub-Form' and I didn't think that could be done in a straight forward way. (but always willing to learn!)
If I was to try this I would have thought that the underlying query on the Main JOB form would have involved joins to the tables holding the Null and NotNull dates, and those criteria would be hard coded in the Query Grid.
That way the Main form would open to show only JOBS meeting the criteria.
Depending on the nature of the data there may be multiple Main forms for the same JOB so the main query may have to Group by JOB; failing that you may have to rely on a correlated sub-query, but I'm pretty certain this is the path you will have to tread.
S7
Hi
It seems to me that you are trying to filter a 'Main' form, using criteria set in the 'Sub-Form' and I didn't think that could be done in a straight forward way. (but always willing to learn!)
If I was to try this I would have thought that the underlying query on the Main JOB form would have involved joins to the tables holding the Null and NotNull dates, and those criteria would be hard coded in the Query Grid.
That way the Main form would open to show only JOBS meeting the criteria.
Depending on the nature of the data there may be multiple Main forms for the same JOB so the main query may have to Group by JOB; failing that you may have to rely on a correlated sub-query, but I'm pretty certain this is the path you will have to tread.
S7
Thanks Sierra7- yes, I created a new query for the new 'filtered' main form that linked the query behind the original main form and the tables behind the two subforms. It seems so obvious now that I've done it!
Angi
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Robert Neville |
last post by:
I would like to add filter functionality to my database whether
through the Main form or the subform. This question may be
rudimentary, yet I have not less experience with filtering data
outside...
|
by: Brian Newman |
last post by:
I've got what is actually a triple-layer nested form. That part works
fine. I've got the first subform related by the right key field to
the main form, then I've got the second subform related to...
|
by: damjanu |
last post by:
Hi All;
I need little help.
I have a datasheet form.
I allow user to do 'filter by selection'.
My form contains a column with values.
As user changes selections, I want to
calculate totals....
|
by: MS |
last post by:
I'm having trouble applying a filter to a subform.
I create a String in a Module based on various selections on the form.
Clicking a button on the "stand alone form" that changes the filter...
|
by: dhowell |
last post by:
In reading some of the posts on this group, it appears as though it is
not strait forward at all to filter a form, which has subforms, by
criteria which are either on subforms or span more than one...
| |
by: Robert |
last post by:
Need some help to stop me going around in circles on this one....
Have a nested subform (subform2) which simulates a continuous form for the
record on the parent subform.
Subform2 has rows of...
|
by: jcf378 |
last post by:
Is it possible to set a main-form with an embedded subform to "Filter by Form", subsequently enter the desired variables in fields in BOTH the main-form and subform, and then save the resulting...
|
by: jambonjamasb |
last post by:
What I am trying to do is have a combo box which allows me to filter for a certain field in a subform.
I can't think how to do this and have tried with the follwoing code. Basically the field in...
|
by: bkberg05 |
last post by:
Hi - I have a form called Vendor (tied to table with same name). Each vendor_id can belong to more than one 'category'. So there's a table called Vendor_Category which contains just vendor_id and...
|
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: 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...
| |
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: 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: 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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |