Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using a form field in a query

Status
Not open for further replies.

bravo6

IS-IT--Management
Mar 23, 2006
83
US
I have a query in which one of my fields is "Invoice date" from a table. As a criteria of that field I am using a date range from a form. The criteria expression is:

Between [forms]![YTD Query Calendar Prelim Results]![monthstart] And [forms]![YTD Query Calendar Prelim Results]![monthend]

The above works fine. So it seems to me that I should be able to add a field to the same query such as:

Date: [forms]![YTD Query Calendar Prelim Results]![monthstart]

As written above the field is looking for data in the same form where my criteria line got it from. For some reason, this field never populates (the results are blank in that field) I don't understand why.
 
Hi

Form has to be open and the field must have a value, is it and has it?

Also

Date:, Date is a reserved Word, (eg Date Function Date()), so it is not wise to use it as a varaible name or an alias

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Ken, Thanks for your answer. Yes the form is open and the field is populated. Again, it's the same form/field that's being used as criteria elsewhere in another field of the same query. This really has me stumped.

D
 
Have you tried changing the name of the alias, as Ken suggested?


-V
 
Yes, that made no difference
 
Sure, here is the SQL view. The problem area is:

[Forms]![YTD Query Calendar Prelim Results]![MonthStart] AS Start

Everything else is Ok.

SELECT DBA_Invoice.BkAgt, DBA_Invoice.InvoiceDate, DBA_Invoice.InvoiceNumber, DBA_Invoice.RevType, DBA_Invoice.TotalCost, AgentSign.[Agent Name], AgentSign.Team, [Forms]![YTD Query Calendar Prelim Results]![MonthStart] AS Start
FROM DBA_Invoice LEFT JOIN AgentSign ON DBA_Invoice.BkAgt = AgentSign.[Agent Sign]
WHERE (((DBA_Invoice.InvoiceDate) Between [forms]![YTD Query Calendar Prelim Results]![monthstart] And [forms]![YTD Query Calendar Prelim Results]![monthend]) AND ((DBA_Invoice.RevType)="a" Or (DBA_Invoice.RevType)="r" Or (DBA_Invoice.RevType)="f"));
 
I'd spell exactly the same the 2 instances of the start parameter ...
 
I'm sorry I'm not following what you are saying.
 
[Forms]![YTD Query Calendar Prelim Results]![MonthStart]
is not spelled the same as
[forms]![YTD Query Calendar Prelim Results]![monthstart]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top