Same criteria for 2 fields

jamphan

Registered User.
Local time
Today, 10:14
Joined
Dec 28, 2004
Messages
143
I have 2 fields in my query, a date received and a date completed. In my query results I need to see all accounts that have a date received in the date range I specify and also accounts that have a date completed in the same range. Is this possible? I have been running into a few road blocks but it seens doable. Thanks for the help.
 
If you are using actual dates:

In your query, under your field in the criteria put:

Example: Between #1/1/2005# and #2/16/2005# (When using actual dates you must use the # signs to let access know that it is a date).

If you are using references to field names:

In your query, under your field in the criteria put:

Example: Between Me!txtBeginDate and Me!txtEndDate

Hope this helps.
 
I am referencing 2 form fields where the user will input the dates they need. The 2 fields are not linked to a table, just the query criteria. How will this work? Also, what is the Me! in front of the text string do?
 
Me is shorthand, valid ONLY on forms and reports, for the current form or report.

Me. is equal to Forms("MyFormName"). where it is used in VBA code in the class module of form "MyFormName". AND - it doesn't work in the context of a general module because the VBA compiler binds it differently in that case. (Won't bind it at all in the module.) So you cannot make a general module's functions and subroutines reference "me." or "me!" - but you CAN pass it as an Actual parameter from the class module, referring to a form or report object, if the corresponding Formal parameter of the routine is a form or report object.
 
Sorry but I think that may have gone above me. In my situation where I have 2 date fields and I want them to return the same criteria from a form field that is not tied to a table only the query criteria, what would this look like? My field names are dtmDateReuqested and dtmDateCompleted.
 
If you don't see what I am talking about, look up help on the Between functions for dates. Microsoft could explain it better than I ever could.
 
dude man!! i've got the same problem. its jus to hard to expain to these clever clogs what ur tryin to achieve. i'm tryin to query 2 fields for the same criteria. i'm only searchin 2 fields for 1 word nd i jus cannot do it captin ..... eeeee by heck
 
To refer to a control (text box, combo or whatever) in a form as a criterion in a query use the syntax:

Forms!MyForm!Mycontrol

Substitute your form name and your control name but keep the Forms! bit.
 
As far as I know, you will need to create two queries. One for 1 date and one for the other. You can then use those queries to create a report. You can design a report and setup to subreports within that report based on your two queries. Or base the report on 1 of your queries and add a subreport to show the results of your second query.

This is how I have done mose of mine.

Hope this helps.
 

Users who are viewing this thread

Back
Top Bottom