Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Date Range Selection the ODBC connection to database

I am having fun and games, trying to take the values entered through a
user form for a start date and end date and then using these dates in
a query.

Has any one ever tried this and how have you passed the values from
the userform into the query ?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default Date Range Selection the ODBC connection to database

The SQL syntax will depend on the provider. This example is based on
Jet for Excel and assumes your dates are in textboxes named
txtStartDate and txtEndDate respectively:

Dim strSql As String
Const DATE_FORMAT As String = "dd mmm yyyy"
strSql = "SELECT Amount FROM [EarningsHistory$]" & _
" WHERE DateEffective BETWEEN " & _
" #" & Format(txtStartDate.Text, DATE_FORMAT) & "#" & _
" AND #" & Format(txtEndDate.Text, DATE_FORMAT) & "#"

The resultant query would look like this:

SELECT Amount FROM [EarningsHistory$]
WHERE DateEffective BETWEEN
#01 JAN 2001# AND #31 DEC 2001#

--

(Steve Mildner) wrote in message . com...
I am having fun and games, trying to take the values entered through a
user form for a start date and end date and then using these dates in
a query.

Has any one ever tried this and how have you passed the values from
the userform into the query ?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel connection to ODBC database Poppe Excel Discussion (Misc queries) 8 April 24th 09 06:16 AM
link ODBC connection to an Oracle database Richard Excel Discussion (Misc queries) 1 November 5th 06 04:29 PM
ODBC connection failed. Jim Moberg Excel Discussion (Misc queries) 0 October 9th 06 03:53 PM
ODBC connection by udl Dorothy[_4_] Excel Programming 1 January 8th 04 05:32 PM
ODBC System DSN Connection Mark[_22_] Excel Programming 4 October 21st 03 10:12 AM


All times are GMT +1. The time now is 07:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"