Criteria Problem

djwasim

Registered User.
Local time
Today, 06:06
Joined
May 29, 2009
Messages
93
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?
 
Last edited:
This link should help you get the correct syntax for referring to sub forms and their controls.
 
use this criterea

Between [Forms]![frmMainForm]![frmreports].[form]![txtdatefrom] And [Forms]![frmMainForm]![frmreports].[form]![txtdateto]
 
I use this formula but there is no any resutl


>=[forms]![ frmMainform]![frmreports].[Form].[txtDateFrom] And <=[forms]![ frmMainform]![Frmreports].[Form].[txtDateTo]

Plz help me
 
I wrote this using the form names you told

where are you using this statement
 
I wrote this using the form names you told

where are you using this statement
 
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.
 
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
 
i am putting the criteria statement in query (date) criteria field
 
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.
 
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.
 
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.
 
How do you hide the Database Window?
Normally I would not expect it to have any effect on the way the progam runs.
 
I use to hide database window from tools> startup option.
 
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?
 
Yes there are prompts appearing for entering range of dates
 
Is there any solution in vb for this problem?
 
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.
 

Users who are viewing this thread

Back
Top Bottom