I have a form (FrmAddQuotes) with a tab control and two pages ( quotes for insurance). I am trying to automatically fill the rate field on the quote subform (FrmQuotesAuto), by a rate from the rates table that meets 4 contditions with an SQL statement. here is my code:
Private Sub Year_AfterUpdate()
Dim strSQL As String
Dim rs As DAO.Recordset
strSQL = "SELECT TblRatesAuto.Rate FROM TblRatesAuto " & _
"WHERE (((TblRatesAuto.Year2)>[Forms]![FrmAddQuotes]![FrmQuotesAuto].[Form]![Year]-1) " & _
"AND ((TblRatesAuto.CoID)=[Forms]![FrmAddQuotes]![FrmQuotesAuto].[Form]![CboCoID]) " & _
"AND ((TblRatesAuto.Product)=[Forms]![FrmAddQuotes]![FrmQuotesAuto].[Form]![CboProduct]) " & _
"AND ((TblRatesAuto.Year1)<[Forms]![FrmAddQuotes]![FrmQuotesAuto].[Form]![Year]+1));"
Set rs = CurrentDb.OpenRecordset(strSQL)
Me.Rate = rs!Rate
rs.Close
Set rs = Nothing
End Sub
i am getting an error message : too few parameters. expected 3
is it a code error or SQL string syntax error? may be both
any help? :banghead:
thanks
Private Sub Year_AfterUpdate()
Dim strSQL As String
Dim rs As DAO.Recordset
strSQL = "SELECT TblRatesAuto.Rate FROM TblRatesAuto " & _
"WHERE (((TblRatesAuto.Year2)>[Forms]![FrmAddQuotes]![FrmQuotesAuto].[Form]![Year]-1) " & _
"AND ((TblRatesAuto.CoID)=[Forms]![FrmAddQuotes]![FrmQuotesAuto].[Form]![CboCoID]) " & _
"AND ((TblRatesAuto.Product)=[Forms]![FrmAddQuotes]![FrmQuotesAuto].[Form]![CboProduct]) " & _
"AND ((TblRatesAuto.Year1)<[Forms]![FrmAddQuotes]![FrmQuotesAuto].[Form]![Year]+1));"
Set rs = CurrentDb.OpenRecordset(strSQL)
Me.Rate = rs!Rate
rs.Close
Set rs = Nothing
End Sub
i am getting an error message : too few parameters. expected 3
is it a code error or SQL string syntax error? may be both
any help? :banghead:
thanks