RE: Too Few Parameters Error
- From: Marnie <Marnie@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 1 Nov 2005 10:19:05 -0800
Duh! I guess I was looking at it so long I didn't notice the syntax. That
fixed the problem. Thanks! But I have another question.. this form has
several subforms. I want to put this code where it will execute and then not
allow the user to move off the main form until the data has been corrected (I
am adding an IF statement based on the value of cntNo). For example, if I
put this on the On Close event is there a way to return control back to the
form if cntNo<>0. Keep in mind the user might use the navigation buttons to
move between forms.
Thanks
Marni
"Klatuu" wrote:
> The real problem here is syntax. You have the reference to the controls on
> your form inside the quotes, so rather than searching for the value in the
> controls, it is trying to match to the literal value of the name of your
> controls. YOu also have too many single quotes in the wrong places. Here is
> an example of what you need for your entire SQL:
>
> & "WHERE (((tblAuditResultQuestions.FacilityCode)= '" & [Form]![frmAudit
> ResultsChange]![txtFacilityCode]) & "' AND " & _
> "((tblAuditResultQuestions.FacilityPlant)= '" & [Form]![frmAudit
> ResultsChange]![txtFacilityPlant]) '" & "' AND "
>
> Use the single quotes for text fields.
> Use # instead of single quotes for date fields.
> Numeric fields need nothing.
>
> "Marnie" wrote:
>
> > I am trying to test the validity of the data on a form before closing the
> > form. I get the error 'Run-Time Error 3061. Too few parameters. Expected
> > 6.' The data in tblAuditResultQuestions comes from a subform. I got the
> > same error when I substituted ME! for [Form]![frmAudit ResultsChange]. Here
> > is the code:
> >
> > Dim strSQL As String
> > Dim rst As DAO.Recordset
> > Dim cntNo As Integer
> > strSQL = "SELECT Count(tblAuditResultQuestions.QuestionNumber) AS CountBad "
> > & _
> > '"FROM tblAuditResultQuestions " & _
> > '"WHERE (((tblAuditResultQuestions.FacilityCode)=[Form]![frmAudit
> > ResultsChange]![txtFacilityCode]) AND " & _
> > '"((tblAuditResultQuestions.FacilityPlant)=[Form]![frmAudit
> > ResultsChange]![txtFacilityPlant]) AND " & _
> > '"((tblAuditResultQuestions.ProcessName)=[Form]![frmAudit
> > ResultsChange]![txtProcessName]) AND " & _
> > '"((tblAuditResultQuestions.AuditDate)=[Form]![frmAudit
> > ResultsChange]![txtAuditDate]) AND " & _
> > '"((tblAuditResultQuestions.Level)=[Form]![frmAudit
> > ResultsChange]![txtLevel]) AND " & _
> > '"((tblAuditResultQuestions.Shift)=[Form]![frmAudit
> > ResultsChange]![txtShift]) AND " & _
> > '"((tblAuditResultQuestions.Pass)='No') AND ((IIf([CorrectiveAction] Is
> > Null,'Y','N'))='Y'));"
> > Set rst = CurrentDb.OpenRecordset(strSQL)
> > cntNo = rst.Fields("CountBad").Value
> > rst.Close
> >
> > Any help would be appreciated
> > Thanks
> > Marni
.
- Prev by Date: RE: Shell command not working at all
- Next by Date: Re: complex select query
- Previous by thread: RE: Shell command not working at all
- Next by thread: too few parameters error
- Index(es):