Using Access 2007 and trying to recycle a method I've used for several years in prvious versions of Access.
After Updating a parameter on a main form I want to pass query logic into query named qdf and make table from the parameters in form. I am receiving Run Time error 3141: The select statement includes a reserved word or an argument name that is mispelled or missing, or the punctuation is incorrect. Can anyone decifer the chnage in reserved words from prior versions of access that would create this error from code below? Thank you in advance.
Private Sub txtPeriodNumber_AfterUpdate()
DoCmd.SetWarnings False
Dim pmDelete As String
pmDelete = ""
pmDelete = pmDelete & "Delete * from GeneralJournalHeaderTbl;"
DoCmd.RunSQL pmDelete
Dim db As Database
Dim qdf As DAO.QueryDef
Dim tbl As TableDef
Set db = CurrentDb()
Set qdf = db.QueryDefs("qdf")
Dim intMarket As String
strProperty = Forms![checkmax]!txtPeriodNumber
Dim StrSQL As String
StrSQL = ""
StrSQL = StrSQL & " SELECT 1 AS DOCNUM, ([Period]+988) AS BATCHID, "
StrSQL = StrSQL & " [MonthName] & 'Close' AS REFERENCE, "
StrSQL = StrSQL & " Calendar.Period AS Period, "
StrSQL = StrSQL & " Calendar.Year AS Year, "
StrSQL = StrSQL & " Calendar.BeginningDate AS BeginningDate, "
StrSQL = StrSQL & " Calendar.EndingDate AS EndingDate, "
StrSQL = StrSQL & " INTO GeneralJournalHeaderTbl "
StrSQL = StrSQL & " FROM Calendar "
StrSQL = StrSQL & " WHERE (((Calendar.Period)=[Forms]![checkmax].[txtPeriodNumber]) "
StrSQL = StrSQL & " AND ((Calendar.Year)=[Forms]![checkmax].[txtYearNumber]));"
Debug.Print StrSQL
qdf.SQL = StrSQL
DoCmd.SetWarnings False
DoCmd.OpenQuery "qdf"
DoCmd.SetWarnings True
End Sub
After Updating a parameter on a main form I want to pass query logic into query named qdf and make table from the parameters in form. I am receiving Run Time error 3141: The select statement includes a reserved word or an argument name that is mispelled or missing, or the punctuation is incorrect. Can anyone decifer the chnage in reserved words from prior versions of access that would create this error from code below? Thank you in advance.
Private Sub txtPeriodNumber_AfterUpdate()
DoCmd.SetWarnings False
Dim pmDelete As String
pmDelete = ""
pmDelete = pmDelete & "Delete * from GeneralJournalHeaderTbl;"
DoCmd.RunSQL pmDelete
Dim db As Database
Dim qdf As DAO.QueryDef
Dim tbl As TableDef
Set db = CurrentDb()
Set qdf = db.QueryDefs("qdf")
Dim intMarket As String
strProperty = Forms![checkmax]!txtPeriodNumber
Dim StrSQL As String
StrSQL = ""
StrSQL = StrSQL & " SELECT 1 AS DOCNUM, ([Period]+988) AS BATCHID, "
StrSQL = StrSQL & " [MonthName] & 'Close' AS REFERENCE, "
StrSQL = StrSQL & " Calendar.Period AS Period, "
StrSQL = StrSQL & " Calendar.Year AS Year, "
StrSQL = StrSQL & " Calendar.BeginningDate AS BeginningDate, "
StrSQL = StrSQL & " Calendar.EndingDate AS EndingDate, "
StrSQL = StrSQL & " INTO GeneralJournalHeaderTbl "
StrSQL = StrSQL & " FROM Calendar "
StrSQL = StrSQL & " WHERE (((Calendar.Period)=[Forms]![checkmax].[txtPeriodNumber]) "
StrSQL = StrSQL & " AND ((Calendar.Year)=[Forms]![checkmax].[txtYearNumber]));"
Debug.Print StrSQL
qdf.SQL = StrSQL
DoCmd.SetWarnings False
DoCmd.OpenQuery "qdf"
DoCmd.SetWarnings True
End Sub