If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Choosing form input on query
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. -- Thanks for any assistance |
#2
|
|||
|
|||
Choosing form input on query
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").I sLoaded 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. "NNlogistics" wrote: 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. -- Thanks for any assistance |
#3
|
|||
|
|||
Choosing form input on query
Thanks Klatuu
I'll need some time to absorb that. -- Thanks for any assistance "Klatuu" wrote: 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").I sLoaded 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. "NNlogistics" wrote: 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. -- Thanks for any assistance |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Controls disappear from Data Entry form | Paul Ponzelli | Using Forms | 10 | February 26th, 2006 05:51 AM |
How do I populate fields in a form from a query? | MAC | Using Forms | 3 | January 12th, 2006 09:01 PM |
Form input in query, Union and crosstab query gives error msg | Christian | Running & Setting Up Queries | 2 | November 17th, 2004 05:00 PM |
Big number gives error! | Sara Mellen | Running & Setting Up Queries | 8 | October 11th, 2004 02:48 AM |
surely a form with a ListBox can be used in a query? | 1.156 | Running & Setting Up Queries | 14 | June 2nd, 2004 04:54 PM |