using unbound form fields in Query criteria

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there, I wanted to use the multi value of an unbound list box in a form as
the criteria for a field in a query... is this possible ? if not what is the
best way to have a query that will only retrieve records from the last three
months (changing over time) without having to enter the new criteria
everytime you run the query. The month field is in a text format too, not a
date format. The Date is separated in to three columns (day, month, year) day
is a byte data type, Month is text and year is integer with max 4 numerals.

Any help would be muchly appreciated, cheers.
 
No. You cannot use the entries in a multi-select list box directly in the
criteria of a query.

You can build the Where clause of the query dynamically using code. Example
in this article:
http://allenbrowne.com/ser-50.html

To retrieve records from the last 3 calendar months, set the Criteria to:
DateAdd("m", -3, Date() - Day(Date())
Results will be unreliable unless you use a Date/Time field, or use CVDate()
around the text field to force it to a real date.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top