Porsche996GT2
Programmer
..with my SQL statement? I'm doing this in VBA and am having problems with the punctuations:
SQL = "SELECT qry2006RenewalsFlagged.PID, qry2006RenewalsFlagged.CID, qry2006RenewalsFlagged.SetID, qry2006RenewalsFlagged.[Group Name], Format(Format([anniversarymonth],""00"") & ""/01/"" & [contractyear],""mm/dd/yyyy"") AS [Renewal Date], Null AS AM, qry2006RenewalsFlagged.underwriter, qry2006RenewalsFlagged.[rate version], qry2006RenewalsFlagged.[ARK quote ID], qry2006RenewalsFlagged.[total members], qry2006RenewalsFlagged.[Target PMPM], qry2006RenewalsFlagged.[Final PMPM], ([Final PMPM]/[Target PMPM])-1 AS [Percent Change], IIf([LoadVariance]=0 And [CreditVariance]=0,0,IIf([LoadVariance]=0 And [CreditVariance]<>0,[CreditVariance],IIf([LoadVariance]<>0 And [CreditVariance]=0,[LoadVariance]))) AS Variance"
SQL = SQL & "FROM qry2006RenewalsFlagged"
SQL = SQL & "WHERE (((qry2006RenewalsFlagged.FDRflag)=" & FDR & ") AND ((qry2006RenewalsFlagged.anniversarymonth) Between [Forms].[frmExcelReports].[cboBegMonth] And [forms].[frmExcelReports].[cboEndMonth]) AND ((qry2006RenewalsFlagged.contractyear) Between [Forms].[frmExcelReports].[cboBegYear] And [forms].[frmExcelReports].[cboEndYear]))"
SQL = SQL & "ORDER BY qry2006RenewalsFlagged.PID, qry2006RenewalsFlagged.CID, qry2006RenewalsFlagged.SetID;"
I keep getting a Run Time Error 3141, saying that there is a reserved word or an argument name that is misspelled or missing, or that the punctuation is incorrect. Any help would be appreciated. Thanks!
SQL = "SELECT qry2006RenewalsFlagged.PID, qry2006RenewalsFlagged.CID, qry2006RenewalsFlagged.SetID, qry2006RenewalsFlagged.[Group Name], Format(Format([anniversarymonth],""00"") & ""/01/"" & [contractyear],""mm/dd/yyyy"") AS [Renewal Date], Null AS AM, qry2006RenewalsFlagged.underwriter, qry2006RenewalsFlagged.[rate version], qry2006RenewalsFlagged.[ARK quote ID], qry2006RenewalsFlagged.[total members], qry2006RenewalsFlagged.[Target PMPM], qry2006RenewalsFlagged.[Final PMPM], ([Final PMPM]/[Target PMPM])-1 AS [Percent Change], IIf([LoadVariance]=0 And [CreditVariance]=0,0,IIf([LoadVariance]=0 And [CreditVariance]<>0,[CreditVariance],IIf([LoadVariance]<>0 And [CreditVariance]=0,[LoadVariance]))) AS Variance"
SQL = SQL & "FROM qry2006RenewalsFlagged"
SQL = SQL & "WHERE (((qry2006RenewalsFlagged.FDRflag)=" & FDR & ") AND ((qry2006RenewalsFlagged.anniversarymonth) Between [Forms].[frmExcelReports].[cboBegMonth] And [forms].[frmExcelReports].[cboEndMonth]) AND ((qry2006RenewalsFlagged.contractyear) Between [Forms].[frmExcelReports].[cboBegYear] And [forms].[frmExcelReports].[cboEndYear]))"
SQL = SQL & "ORDER BY qry2006RenewalsFlagged.PID, qry2006RenewalsFlagged.CID, qry2006RenewalsFlagged.SetID;"
I keep getting a Run Time Error 3141, saying that there is a reserved word or an argument name that is misspelled or missing, or that the punctuation is incorrect. Any help would be appreciated. Thanks!