Results 1 to 3 of 3

Thread: Using SQL commands with Access

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    20

    Using SQL commands with Access

    Does anyone have any idea why the code below works on about twenty machines but not one of them. They are using Windows 98. Date1 and Date2 are fields in the access database and there are matches for the search I am doing so the recordset should not be empty.
    Thanks.

    Dim db1 As DAO.Database
    Dim rs1 As DAO.Recordset
    Dim myws As Workspace
    Dim sqlstr As String
    Dim TodaysDate As String

    TodaysDate = Format(Date, "yyyymmdd")
    sqlstr = "select * from TestTable where val(Date1) <= val(" + TodaysDate + ") and val(Date2) >= val(" + TodaysDate + ") order by IntNo"

    Set myws = DBEngine.Workspaces(0)

    Set db1 = myws.OpenDatabase("C:\Test.mdb")
    Set rs1 = db1.OpenRecordset(sqlstr)

    If rs1.BOF And rs1.EOF Then
    MsgBox "It doesn't work"
    Else
    MsgBox "It works"
    End If

    End Sub

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    What error do you get on the one that doesn't work?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    20

    Red face Sorted

    Now sorted thanks. System date was incorrect. Doh !

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