View Full Version : Criteria Problem
djwasim 06-26-2009, 10:34 PM Hello Dear All
i am using this criteria in query to generate a report when i put dates in a form named "frmReports" in which the fields are named "txtdatefrom" & "txtDateTo"
the criteria is.......
>=[forms]![frmReports]![txtDateFrom] And <=[forms]![frmReports]![txtDateTo]
Using this criteria the report gives me true result.
But now the problem is that the form "frmReports" is linked with an other form named "frmMainform" as a sub form.
which criteria i should use to get true results?
John Big Booty 06-26-2009, 10:53 PM This link (http://www.mvps.org/access/forms/frm0031.htm) should help you get the correct syntax for referring to sub forms and their controls.
khawar 06-26-2009, 11:05 PM use this criterea
Between [Forms]![frmMainForm]![frmreports].[form]![txtdatefrom] And [Forms]![frmMainForm]![frmreports].[form]![txtdateto]
djwasim 06-26-2009, 11:10 PM I use this formula but there is no any resutl
>=[forms]![ frmMainform]![frmreports].[Form].[txtDateFrom] And <=[forms]![ frmMainform]![Frmreports].[Form].[txtDateTo]
Plz help me
khawar 06-26-2009, 11:13 PM I wrote this using the form names you told
where are you using this statement
khawar 06-26-2009, 11:14 PM I wrote this using the form names you told
where are you using this statement
djwasim 06-26-2009, 11:19 PM Actually i have linked the form"frmMainform" with a sub form (unbound object)
"frmReports" For which i use........
Me.Object2.SourceObject = "frmreports"
Me.Object2.Form.DataEntry = True
Me.Object2.Form.AllowAdditions = True
Me.Object2.Form.AllowEdits = True
Now i think i have clear something more for you.
khawar 06-26-2009, 11:22 PM But my question was where are you putting the criterea statement
I assumed that you have a main form and a sub form from where the query will get data in that case my statement should work
djwasim 06-26-2009, 11:27 PM i am putting the criteria statement in query (date) criteria field
khawar 06-26-2009, 11:29 PM then if form names are correct it should work
djwasim 06-26-2009, 11:35 PM i am telling you the forms names.......
Main form is ....... frmMainform
In the main form unbound object name is ........object2
Sub Form Is ........frmReports
when i open the main main form then unbound object opens the subform using this vb code
Me.Object2.SourceObject = "frmreports"
Me.Object2.Form.DataEntry = True
Me.Object2.Form.AllowAdditions = True
Me.Object2.Form.AllowEdits = True
Then i wrote the opening and ending dates in both fields named
txtDatefrom and txtDateto
now i think you understand whole project.
djwasim 06-28-2009, 07:13 PM Plz any one help me.
Galaxiom 06-28-2009, 08:06 PM There is a misunderstanding between the name of the subform control (Object2) and the form object it holds (frmReports).
You need to refer to the subform control on the main form not the form object itself.
For a field in the subform:
[Forms]![frmMainForm]![Object2].[form]![txtdatefrom]
Although technically the subform control is a type of object I would not tend to use this as a name and keep Object at the higher level such as forms themselves.
djwasim 06-29-2009, 08:43 PM you have solve my problem but now another problem arises
when i use to hide database window then this code does not show me the report result
but when i use to unhide the database window then this code shows me true result.
plz help me because i want to hide the database window and get true result.
Galaxiom 06-29-2009, 08:58 PM How do you hide the Database Window?
Normally I would not expect it to have any effect on the way the progam runs.
djwasim 06-29-2009, 10:23 PM I use to hide database window from tools> startup option.
Galaxiom 06-29-2009, 10:28 PM I think you should post this problem separately in the general category. It really shouldn't make any difference but maybe someone has an insight and they are more likely to look at a fresh topic.
Describe in what way the results are different depending on the whether the window is hidden or not. Are there error mesages or prompts for values for example or is the result just not the value you expected?
djwasim 06-29-2009, 10:51 PM Yes there are prompts appearing for entering range of dates
djwasim 06-29-2009, 10:53 PM Is there any solution in vb for this problem?
Galaxiom 06-29-2009, 10:57 PM Yes there are prompts appearing for entering range of dates
Do these prompts appear both when the Database Window is open and when it is closed?
If they only appear when the Window is closed it would suggest that Access is unable to find the normal location of these fields when the Window is closed.
djwasim 06-29-2009, 11:16 PM yes these prompts appears only when the database window is in hidden mode
Galaxiom 06-29-2009, 11:25 PM What is the usual source of the date range in the query? Is it a form?
This form must be open otherwise Access cannot find the date range textboxes.
When this happens Access prompts for the the dates to be manually entered.
djwasim 06-30-2009, 12:31 AM yes source is a form and that form is opened
djwasim 06-30-2009, 12:33 AM is it possible that we can use the criteria parameter in report instead of a query?
djwasim 06-30-2009, 01:07 AM any one help me plz
|