Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default help with passing date to access as parameter query(code included)

The code below does not seem to work and I was wondering if anyone could tell
me why. The last line fails when I try to open the recordset.

Your help is appreciated.

Dim i As Long
Dim lngMove As Long
Dim strDateCheck As String
Dim strCreationData As String
Dim strEditDate As String
Dim sDate As String

Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long, c As Long

Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.Oledb.4.0; " & _
"Data Source=\\Gresnt07\Complaints\BreakManager.mdb;"

Set rs = New ADODB.Recordset
sDate = Sheet1.Cells(2, 1).Value
rs.Open "Select tblBreaks.BrkDate, tblBreaks.BrkTime, tblBreaks.brkCrew FROM
tblBreaks WHERE tblBreaks.BrkDate = sDate, cn, adOpenDynamic,
adLockOptimistic"

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default help with passing date to access as parameter query(code included)

Vince

look at the last few lines below. I think you were not properly handling the
date.

Set rs = New ADODB.Recordset
' need to check the format of the date and the date format in the database
sDate = "#" & Format(Sheet1.Cells(2, 1).Value, "mm/dd/yyyy") & "#"
rs.Open "Select tblBreaks.BrkDate, tblBreaks.BrkTime, " & _
"tblBreaks.brkCrew " & _
"FROM tblBreaks " & _
"WHERE tblBreaks.BrkDate = " & sDate, _
cn, adOpenDynamic, adLockOptimistic



--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"Vince" wrote:

The code below does not seem to work and I was wondering if anyone could tell
me why. The last line fails when I try to open the recordset.

Your help is appreciated.

Dim i As Long
Dim lngMove As Long
Dim strDateCheck As String
Dim strCreationData As String
Dim strEditDate As String
Dim sDate As String

Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long, c As Long

Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.Oledb.4.0; " & _
"Data Source=\\Gresnt07\Complaints\BreakManager.mdb;"

Set rs = New ADODB.Recordset
sDate = Sheet1.Cells(2, 1).Value
rs.Open "Select tblBreaks.BrkDate, tblBreaks.BrkTime, tblBreaks.brkCrew FROM
tblBreaks WHERE tblBreaks.BrkDate = sDate, cn, adOpenDynamic,
adLockOptimistic"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default help with passing date to access as parameter query(code inclu

Thank you, that worked great and is exactly what I needed.

"Martin Fishlock" wrote:

Vince

look at the last few lines below. I think you were not properly handling the
date.

Set rs = New ADODB.Recordset
' need to check the format of the date and the date format in the database
sDate = "#" & Format(Sheet1.Cells(2, 1).Value, "mm/dd/yyyy") & "#"
rs.Open "Select tblBreaks.BrkDate, tblBreaks.BrkTime, " & _
"tblBreaks.brkCrew " & _
"FROM tblBreaks " & _
"WHERE tblBreaks.BrkDate = " & sDate, _
cn, adOpenDynamic, adLockOptimistic



--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"Vince" wrote:

The code below does not seem to work and I was wondering if anyone could tell
me why. The last line fails when I try to open the recordset.

Your help is appreciated.

Dim i As Long
Dim lngMove As Long
Dim strDateCheck As String
Dim strCreationData As String
Dim strEditDate As String
Dim sDate As String

Dim cn As ADODB.Connection, rs As ADODB.Recordset, r As Long, c As Long

Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.Oledb.4.0; " & _
"Data Source=\\Gresnt07\Complaints\BreakManager.mdb;"

Set rs = New ADODB.Recordset
sDate = Sheet1.Cells(2, 1).Value
rs.Open "Select tblBreaks.BrkDate, tblBreaks.BrkTime, tblBreaks.brkCrew FROM
tblBreaks WHERE tblBreaks.BrkDate = sDate, cn, adOpenDynamic,
adLockOptimistic"

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
pass parameter to access query Bill Manville Links and Linking in Excel 4 May 1st 23 03:45 AM
Passing parameter to a select query Seamus Conlon Excel Programming 12 September 18th 06 03:13 PM
passing parameter to a ms query redf1re Excel Programming 6 February 7th 06 10:39 PM
Passing parameter to a query Dwaine Horton[_3_] Excel Programming 6 April 26th 05 02:24 AM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Excel Discussion (Misc queries) 1 December 13th 04 07:54 PM


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

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

About Us

"It's about Microsoft Excel"