Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Choosing form input on query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NNlogistics - 03 Mar 2006 17:04 GMT
Is there a way to choose which form to pick as the input on a query.  
When I am running a query that requires a date range, I build a form with
the dates and reference the form in the criteria.  If there were 2 forms that
may provide input to a query, I thought it would look like

Between [Forms]![frmSelectRevenueDates]![txtBeginningDate] And
[Forms]![frmSelectRevenueDates]![txtEndingDate] Or Between
[Forms]![frmSelectRevenueDatesforSummaryRpt]![txtBeginningDate] And
[Forms]![frmSelectRevenueDatesforSummaryRpt]![txtEndingDate]

It brings up a dialog box asking for input from the form not open.

Hope that makes sense.
Signature

Thanks for any assistance

Klatuu - 03 Mar 2006 17:44 GMT
That will not work, because the entire statment is evaluated before
execution.  A way around that would be to write a function to determine which
form is open, evaluate the dates, and return a true of false value.  Then,
change the criteria in your query to use the function.  The function will
have to be a Public Function in a standard module.  It might go something
like this:

Public Function IsGoodRevenueDate(dtmSomeDate) As Boolean
Dim frm As Form

   If Currentproject.AllForms("frmSelectRevenueDates").IsLoaded Then
       Set frm = "frmSelectRevenueDates"
   ElseIf Currentproject.AllForms( _
           "frmSelectRevenueDatesforSummaryRpt").IsLoaded Then
       Set frm = "frmSelectRevenueDatesforSummaryRpt"
   End If

   With frm
       If dtmSomeDate >= .txtBeginningDate And _
               dtmSomeDate <= .txtEndingDate Then
           IsGoodRevenueDate = True
       Else
           IsGoodRevenueDate = False
       End If
   End With

   Set frm = Nothing

End Function

Then Change your query criteria to:

     IsGoodRevenueDate ([DateFieldName])

DateFieldName is the name of the field you want to evaluate.

> Is there a way to choose which form to pick as the input on a query.  
> When I am running a query that requires a date range, I build a form with
[quoted text clipped - 9 lines]
>
> Hope that makes sense.
NNlogistics - 03 Mar 2006 17:58 GMT
Thanks Klatuu

I'll need some time to absorb that.
Signature

Thanks for any assistance

> That will not work, because the entire statment is evaluated before
> execution.  A way around that would be to write a function to determine which
[quoted text clipped - 45 lines]
> >
> > Hope that makes sense.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.