How do I do this? (query criteria)

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

Guest

Hi,

I have a table of week ending dates. I want the user to enter a year into a
textbox on a form and have a listbox display all weeks ending in that year.

I can get the results that I want if I enter the listbox's RowSouce query
criteria as "between #1/1/2004# and #12/31/2004#", but I want to get the same
results with the user entering "2004" into the textbox. Can this be done in
the query, or do I need to write code to build a string and insert the string
into a SQL statement?

Thanks in advance for any help provided.
 
Enter the following expression in the criteria:
Between DateSerial(Me!NameOfTextbox,1,1) And
DateSerial(Me!NameOfTextbox,12,31)
 
Thanks PC,

I don't know why, but a parameter box pops up when I use "Me" in the
expression. It works fine (with no popup) after modifying the "Me!" portion
to "[Forms]![NameOfForm]!"
 
What you did is correct. "Me" is not recognised outside the context of VBA
code for the relevant Form.
 
Back
Top