Passing specific ComboBox info to a Query

  • Thread starter pwdpwd via AccessMonster.com
  • Start date
P

pwdpwd via AccessMonster.com

Hi - hope someone can help.

What I'm trying to do is to select service dates within a 53 week year - and
the year doesn't always start on the 1st Jan. When I use specific criteria in
the ServiceDate field in the query (dd/mm/yyyy):

"Between #28/12/2009# And (#28/12/2009#+371)"

it works fine.

When I use a text box (set to dd/mm/yyyy) and set the criteria to

"Between Forms!FRM_FormName!TextBox and (Forms!FRM_FormName!TextBox +371)"

it also works fine

I don't want the user to have to remember the exact start date of each year,
so I created a tbltablestartdate table; with 3 fields - ID, year and
yearstartdate.

On the form I created & bound a combobox to that table, but only display the
year. I want to let the user select the year (yyyy) but use the yearstartdate
(dd/mm/yyyy) as the criteria in the query. I tried substituting 'Combobox'
for 'TextBox' but that doesnt work, as (presumably) the combobox is passing
the data for the year, not the yearsstartdate.

I'm sure that it must be possible, but not sure how - any help would be much
appreciated.
 
J

John Spencer

You should set the combobox's bound column to 3 (or whatever the column number
is that contains YearStartDate. I assume that YearStartDate is a date field.

Also, I would make sure that the query understood the data type.

Between CDate(Forms![FRM_FormName]![ComboBox]) and
DateAdd("d",371,Forms![FRM_FormName]![ComboBox])

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
P

pwdpwd via AccessMonster.com

Hi John

Many thanks - that works fine

John said:
You should set the combobox's bound column to 3 (or whatever the column number
is that contains YearStartDate. I assume that YearStartDate is a date field.

Also, I would make sure that the query understood the data type.

Between CDate(Forms![FRM_FormName]![ComboBox]) and
DateAdd("d",371,Forms![FRM_FormName]![ComboBox])

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
Hi - hope someone can help.
[quoted text clipped - 24 lines]
I'm sure that it must be possible, but not sure how - any help would be much
appreciated.
 

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

Top