If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Other > Cannot Select Date from ACCESS in SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-15-03, 11:01
mrhyman mrhyman is offline
Registered User
 
Join Date: Oct 2003
Posts: 30
Post Cannot Select Date from ACCESS in SQL

I am trying to select a record from a Table base on a certain date that I select on an ActiveX calendar control on my Form. MY Db is Access XP and here is the code.

Private Sub CommandClick_Click()

Dim DateJ As Date
Dim strSQL As String
Dim RS As ADODB.Recordset
Dim Cn As ADODB.Connection
Dim nom As String
Dim Sconnect As String

'Database Path
Sconnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\Markus\My Documents\Projet Sesco\Equipe de Vente.mdb"

Set Cn = New ADODB.Connection
Set RS = New ADODB.Recordset
Cn.Open Sconnect

Calendar5.SetFocus
DateJ = Calendar5.Value

strSQL = "SELECT * FROM CollègeQ WHERE " & DateJ & " = Date "
' strSQL = "SELECT * FROM CollègeQ"

Set RS = Cn.Execute(strSQL)

If Not (RS.BOF And RS.EOF) Then

TextTest.SetFocus
TextTest.Text = RS.Fields("Date").Value

Else
MsgBox "No Record Found"
End If

Cn.Close
Set RS = Nothing
Set Cn = Nothing

End Sub


When I comment out the First strSQL I always obtain the first column in the table. Using the first strSQL I get no record found. However, I know the records exists for the dates I select in the calendar. I have a test date in the table which is 1/1/2003 and I select this date on the calendar and still get no result when I click on the command button.

Any advice would be really appreciated.

Mark
Attached Files
File Type: zip equipe de vente.zip (693.6 KB, 28 views)
Reply With Quote
  #2 (permalink)  
Old 11-12-03, 06:27
vb6dv vb6dv is offline
Registered User
 
Join Date: Oct 2003
Location: France
Posts: 10
Re.

2 pistes :
1. Evite de taper des noms de champs avec des accents et ca passera peut etre mieux.
2. caste ton champ date en string
Reply With Quote
  #3 (permalink)  
Old 11-13-03, 14:16
mrhyman mrhyman is offline
Registered User
 
Join Date: Oct 2003
Posts: 30
Merci Ca Marche
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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