By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,911 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Access 2003 Date Range

P: 1
Help!
I have a form that contains a From and To - Date Fields and I would like to be able to enter the dates and then click a button labeled 'Display' which will then list records that are between the specified date ranges. The records are to display on a list box. I have found some help in this forum but it all seems to be centered around displaying the results on a report. I need the results on a list box.

I am a newbie to Access and this forum so please be gentle!
Thanks
Dec 29 '06 #1
Share this Question
Share on Google+
2 Replies


nico5038
Expert 2.5K+
P: 3,072
In the OnClick of the button fill the listbox rowsource like:

me.listboxname.rowsource = "select a, b from tblZ where dateX between #" & me.txtStartdate & "# and #" & me.txtEnddate & "# "
me.refresh

Getting the idea ?

Nic;o)
Dec 29 '06 #2

NeoPa
Expert Mod 15k+
P: 31,263
There is a slight possibility of date problems with this, otherwise perfect, code.
To avoid any such issue (See Literal DateTimes and Their Delimiters (#).) try this doctored version :
Expand|Select|Wrap|Line Numbers
  1. Me.ListBoxName.RowSource = "SELECT a, b FROM tblZ WHERE dateX Between " & Format(Me.txtStartDate,"\#m/d/yyyy\#") & " And " & Format(Me.txtEndDate,"\#m/d/yyyy\#")
  2. Me.Requery
Dec 30 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.