Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You are using DAO, so I re-wrote the sub.....

    You turned off warnings, but didn't turn them on again. When the sub ends, warnings should automatically be turned on again, but I never use "Set Warnings off" so I'm not really sure.

    Using the EXECUTE method bypasses the Access SQL interpreter and is faster and doesn't require you to set warnings off.


    Code:
    Private Sub btn_Classes_by_Date_Click()
        Dim dB As DAO.Database
        Dim strSQL As String
    
        Set dB = CurrentDb
    
        strSQL = "DELETE * FROM Scheduled_For"
        dB.Execute strSQL, dbFailOnError
    
        strSQL = "INSERT INTO Scheduled_For(MRN,Patient_Name,Surgery_Date,Scheduled_For,Enrolled_Date) "
        strSQL = strSQL & " SELECT MRN,Patient_Name,Surgery_Date,Scheduled_For,Enrolled_Date "
        strSQL = strSQL & " FROM Total_Joint_Readiness "
        strSQL = strSQL & " WHERE Scheduled_For >= #" & Me!beginDate & "# AND Scheduled_For <= #" & Me!endDate & "# ;"
        ' I would think about using the following
        '    strSQL = strSQL & " WHERE Scheduled_For Between #" & Me!beginDate & "# AND #" & Me!endDate & "# ;"
    
        '    Debug.Print strSQL
    
        dB.Execute strSQL, dbFailOnError
    
        DoCmd.OpenQuery "Classes_By_Date", , acReadOnly
    
    
        Set dB = Nothing
    End Sub

    Just a suggestion........

  2. #17
    kawi6rr is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    39
    Awesome! Thanks I'll give your suggestions a try.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. "Too complex query" for a Simple Select Query
    By dragon232 in forum Queries
    Replies: 3
    Last Post: 11-29-2016, 02:45 PM
  2. Novice Needs Help With Simple Select Queries
    By GAtkins in forum Queries
    Replies: 5
    Last Post: 11-26-2013, 04:36 PM
  3. Simple Select Query
    By Plee in forum Queries
    Replies: 2
    Last Post: 04-18-2011, 02:34 PM
  4. Simple Select query
    By sandlucky in forum Queries
    Replies: 3
    Last Post: 03-30-2011, 04:26 AM
  5. Replies: 2
    Last Post: 03-31-2009, 11:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums