Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003

    Post Unanswered: 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

    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.Text = RS.Fields("Date").Value

    MsgBox "No Record Found"
    End If

    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.

    Attached Files Attached Files

  2. #2
    Join Date
    Oct 2003


    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

  3. #3
    Join Date
    Oct 2003
    Merci Ca Marche

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts