Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 23rd, 2004, 05:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

LOL, glad you got it working now.
 
Old December 17th, 2004, 01:47 PM
Registered User
 
Join Date: Dec 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hwoBU
Default

Here is a replacement piece of code that is a little cleaner & should fix some of the problems.

This code is updated with the assumption that the [Revised Completion Date] field was built in the table to the Date/Time format (not text).

Another suggestion would be to include the tablename or alias on every field being queried (even if just for a comparison).


Private Sub CreateReportSet(RptId As Long)
On Error goto Err_CreateReportSet
    Dim myDb As Database
    Dim strSQL As String
    Dim strClosed As String

    If NOT RptId = 0 Then
        Set myDb = CurrentDb

        strClosed = """Closed"""
        strSQL = "INSERT INTO [WeeklyRpt] ([ReportId], [ProjectId], [PM]) " & _
                  "SELECT " & Cstr(RptId) & " , [Prj].[ProjectId], [Prj].[PM] " & _
                  "FROM [Projects] AS Prj" & _
                  "WHERE IsNull([Last Report]) " & _
                  "OR [Last Report] <> " & strClosed & " " & _
                  "OR ([Last Report] = " & strClosed & " AND DateDiff("y",[Revised Completion Date], #12/31/2003#) > 0);"
        myDb.Execute strSQL
        Set myDb = Nothing
    End If
Exit_CreateReportSet:
    set myDb = Nothing
    exit sub
Err_CreateReportSet:
    msgbox "Put your CreateReportSet error message here!"
    resume Exit_CreateReportSet:

End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Update query (error message) Neal SQL Server 2000 1 August 3rd, 2007 08:57 PM
Update table using SQL query from form pater53 Access VBA 4 January 24th, 2007 11:24 AM
I solved insert query.now see this Update Query. amit_mande@yahoo.com VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Update query equivalent in SQL Mitch SQL Server 2000 5 May 5th, 2005 05:14 AM
update query? robb Access 4 May 19th, 2004 04:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.