syntax for textbox value into query criteria

N

NetworkTrade

Have a query criteria to find all employees that have a hire-date anniversary
based on the month selected. Obviously there are various hire days and
years....which isn't important...just trying to find everyone's anniversary
by the month.

In the table the hire dates are stored 1/1/2005 etc.

I can manually put in criteria of: Like "3/*/*" and it correctly returns
all employees with a hire date in March month 3

In the Form there is a simple listbox of all Months with first column number
1 to 12 which is bound.

I want the month number selected in the listbox to appear in the query
criteria.

So have attempted the query criteria:

Like "&[Forms]![A-SelectMonthForm].[MonthListbox]&/*/*"

Like "[Forms]![A-SelectMonthForm].[MonthListbox]/*/*"

Like "[Forms!A-SelectMonthForm.MonthListbox]/*/*"

not working.....what am I missing??
 
M

Marshall Barton

NetworkTrade said:
Have a query criteria to find all employees that have a hire-date anniversary
based on the month selected. Obviously there are various hire days and
years....which isn't important...just trying to find everyone's anniversary
by the month.

In the table the hire dates are stored 1/1/2005 etc.

I can manually put in criteria of: Like "3/*/*" and it correctly returns
all employees with a hire date in March month 3

In the Form there is a simple listbox of all Months with first column number
1 to 12 which is bound.

I want the month number selected in the listbox to appear in the query
criteria.

So have attempted the query criteria:

Like "&[Forms]![A-SelectMonthForm].[MonthListbox]&/*/*"

Like "[Forms]![A-SelectMonthForm].[MonthListbox]/*/*"

Like "[Forms!A-SelectMonthForm.MonthListbox]/*/*"

not working.....what am I missing??


You are trying to use string comparisons on a date/time type
value? A better way would be to add a calculated field
(with Show unchecked) to the query:

Expr: Month(hiredate)

and use the criteria:

Forms!A-SelectMonthForm.MonthListbox


If your date is stored in a Text field, the syntax would be:
Like [Forms]![A-SelectMonthForm].[MonthListbox] & "/*/*"
 
N

NetworkTrade

ah - headslap thanks ....thinking in terms of text strings for a date value....

appreciate the calculated value advice - that would not have been intuitive
for me...

gracias
--
NTC


Marshall Barton said:
NetworkTrade said:
Have a query criteria to find all employees that have a hire-date anniversary
based on the month selected. Obviously there are various hire days and
years....which isn't important...just trying to find everyone's anniversary
by the month.

In the table the hire dates are stored 1/1/2005 etc.

I can manually put in criteria of: Like "3/*/*" and it correctly returns
all employees with a hire date in March month 3

In the Form there is a simple listbox of all Months with first column number
1 to 12 which is bound.

I want the month number selected in the listbox to appear in the query
criteria.

So have attempted the query criteria:

Like "&[Forms]![A-SelectMonthForm].[MonthListbox]&/*/*"

Like "[Forms]![A-SelectMonthForm].[MonthListbox]/*/*"

Like "[Forms!A-SelectMonthForm.MonthListbox]/*/*"

not working.....what am I missing??


You are trying to use string comparisons on a date/time type
value? A better way would be to add a calculated field
(with Show unchecked) to the query:

Expr: Month(hiredate)

and use the criteria:

Forms!A-SelectMonthForm.MonthListbox


If your date is stored in a Text field, the syntax would be:
Like [Forms]![A-SelectMonthForm].[MonthListbox] & "/*/*"
 
Top