Results 1 to 2 of 2

Thread: Another Sql Q.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Freeport
    Posts
    204

    Post

    I want to SQL example Jan 3th and Dec 18th. Were the Month is a field and the date is a field. Here how I trying to do it
    a,b,c,d are given by user where d = Dec, b = jan, c = 18 and a = 3
    Dim sql14 As String
    sql14 = "Select * from days where month between '" & d & "' and '" & b & "' and DAte between '" & c & "' and '" & a & "'"
    Set db = OpenDatabase(txtPath)
    Set dbs = db.OpenRecordset(sql14)
    Set Data2.Recordset = dbs
    dbs.Close
    db.Close

  2. #2
    Guest

    Post

    This is the way I do it:

    Code:
    Option Explicit
    Dim db As Database
    Dim rs As Recordset
    Dim SQLString As String
    Dim FromDate As String
    Dim ToDate As String
    
    Assign FromDate and Todate using the format command to match your data here
    FromDate = Format(d & c , "mmm/dd")
    ToDate = Format(b & a , "mmm/dd")
    
    Set db = OpenDatabase("Your Database Here")
    SQLString = "SELECT * From days WHERE (((month)>#" & d & "# And (month)<#" & b & "# And (Date)>#" & c & "# And (month)<#" & a & "#))"
    
    Set rs = db.OpenRecordset(SQLString)
    
    If rs.BOF = True And rs.EOF = True Then
        MsgBox ("No Record in Range")
        Exit Sub
        rs.Close
        db.Close
    End If
    
    Your process here
    
    rs.Close
    
    db.Close
    
    End Sub

    [This message has been edited by Boothman_7 (edited 02-02-2000).]

    [This message has been edited by Boothman_7 (edited 02-02-2000).]

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