pklocke
06-25-2010, 10:25 AM
I have the following code, that is generating an error 3219, Invalid Operation, at the line that is BOLD. The value of strSQL at that point is:
SELECT [LogTable].* INTO [Current Changes] FROM [LogTable] WHERE ((([LogTable].Timestamp)=#06-25-2010#));
Any idea what this is trying to tell me? I think everything "looks" right to me...but I am kind of a noob...thx!
pklocke
------------------------------------------------------------------
Sub testPrintLog()
Dim returncode As Long
returncode = PrintLog(Now(), "Current Changes")
MsgBox "Total Records: " & returncode
End Sub
------------------------------------------------------------------
Public Function PrintLog(logdate As Date, CurrentLogTable As String) As Long
Dim strSQL, LogQueryName As String
LogQueryName = "LQ01-Todays Log Query"
strSQL = "SELECT [LogTable].* INTO [" & CurrentLogTable & "] FROM [LogTable] WHERE ((([LogTable].Timestamp)=" & Format(logdate, "\#mm-dd-yyyy\#") & "));"
On Error Resume Next
Set dbs = CurrentDb
dbs.QueryDefs.Delete LogQueryName
On Error GoTo ErrorHandler
Set qdf = dbs.CreateQueryDef(Name:=LogQueryName, sqltext:=strSQL)
Debug.Print strSQL
Set rst = dbs.OpenRecordset(Name:=strSQL)
With rst
.MoveFirst
.MoveLast
PrintLog = .RecordCount
End With
ErrorHandlerExit:
Exit Function
ErrorHandler:
If Err.Number = 3021 Then
PrintLog = 0
Resume ErrorHandlerExit
Else
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End If
End Function
SELECT [LogTable].* INTO [Current Changes] FROM [LogTable] WHERE ((([LogTable].Timestamp)=#06-25-2010#));
Any idea what this is trying to tell me? I think everything "looks" right to me...but I am kind of a noob...thx!
pklocke
------------------------------------------------------------------
Sub testPrintLog()
Dim returncode As Long
returncode = PrintLog(Now(), "Current Changes")
MsgBox "Total Records: " & returncode
End Sub
------------------------------------------------------------------
Public Function PrintLog(logdate As Date, CurrentLogTable As String) As Long
Dim strSQL, LogQueryName As String
LogQueryName = "LQ01-Todays Log Query"
strSQL = "SELECT [LogTable].* INTO [" & CurrentLogTable & "] FROM [LogTable] WHERE ((([LogTable].Timestamp)=" & Format(logdate, "\#mm-dd-yyyy\#") & "));"
On Error Resume Next
Set dbs = CurrentDb
dbs.QueryDefs.Delete LogQueryName
On Error GoTo ErrorHandler
Set qdf = dbs.CreateQueryDef(Name:=LogQueryName, sqltext:=strSQL)
Debug.Print strSQL
Set rst = dbs.OpenRecordset(Name:=strSQL)
With rst
.MoveFirst
.MoveLast
PrintLog = .RecordCount
End With
ErrorHandlerExit:
Exit Function
ErrorHandler:
If Err.Number = 3021 Then
PrintLog = 0
Resume ErrorHandlerExit
Else
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End If
End Function