Results 1 to 3 of 3

Thread: Not working correctly

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509

    Not working correctly

    My aim below is to select all invoices where the user is a specfic user (works correctly) and the date = today (using system date-not working correctly)

    can someone help me out please?

    VB Code:
    1. Public Function GetData() As ADODB.Recordset
    2.    Dim strsql As String
    3.    ' Dim r As ADODB.Recordset '
    4.    Dim c As ADODB.Connection
    5.    Dim multipledate
    6.     raised = FrmInvoice.StatusBar1.Panels(3).Text
    7.   multipledate = Date
    8.    Set c = New ADODB.Connection
    9.    c.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False; Data Source=.\Invoice.mdb;"
    10.    c.Open
    11.  
    12.    strsql = "SELECT * from Invoice WHERE RaisedBy = '" & raised & "' AND [Date] = '" & multipledate & "' "
    13.    'strsql = strsql & "WHERE Raisedby = '" & raised & "' "
    14.    'Set rsquery = New ADODB.Recordset
    15.    
    16.    
    17.       rsquery.Open strsql, c, adOpenDynamic, adLockPessimistic
    18.  
    19.    Set GetData = rsquery
    20. End Function

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Not working correctly

    i believe you have to use # date # to query by date

    rgds pete

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Not working correctly

    Try putting # signs around your date variable, like:
    Code:
    #" & multipledate & "#

Posting Permissions

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



Click Here to Expand Forum to Full Width