[AccessD] Parameter Queries via Code

Admin Sparky dba.email at gmail.com
Fri Apr 29 12:58:22 CDT 2005


Well now...that was interesting...now I get a very specific message:
"Data type mismatch in criteria expression."

When viewed in the Locals window the first parameter value is "#10/1/2004#".
Prior to this run, it read "10/1/2004".  In both cases the Type is
listed as Variant/String.

I'm wondering if the problem is the quotes.  For instance, another
property for qdfMetrics is DateCreated.  The value for DateCreated
contains no quotes it reads: #4/28/2005 12:46:53 PM#, and the Type is
listed as Variant/Date.

I tried this:
qdfMetrics.Parameters(0) = DateValue(Forms!frmDatePicker!Text14)
...but the Type was still listed as Variant/String with a value of
"10/1/2004".


...frustratingly yours,


Mark Mitsules




On 4/29/05, Gustav Brock <Gustav at cactus.dk> wrote:
> Hi Mark
> 
> Those textboxes probably contain dates:
> 
> 3.        qdfMetrics.Parameters(0) = "#" & Forms!frmDatePicker!Text14 &
> "#"
> 4.        qdfMetrics.Parameters(1) = "#" & Forms!frmDatePicker!Text16 &
> "#"
> 
> You may even need to format these to US date format:
> 
> 3.        qdfMetrics.Parameters(0) = "#" &
> Format(Forms!frmDatePicker!Text14, "m\/d\/yyyy") & "#"
> 4.        qdfMetrics.Parameters(1) = "#" &
> Format(Forms!frmDatePicker!Text16, "m\/d\/yyyy") & "#"
> 
> /gustav
> 
> >>> dba.email at gmail.com 04/29 7:02 pm >>>
> Thank you Charlotte, that worked, but I'm still not getting past line
> 5...I'm now getting "Type mismatch (Error 13)".
> 
> 1.        Set db = CurrentDb
> 2.        Set qdfMetrics = db.QueryDefs("qryMyQuery")
> 3.        qdfMetrics.Parameters(0) = Forms!frmDatePicker!Text14
> 4.        qdfMetrics.Parameters(1) = Forms!frmDatePicker!Text16
> 5.        Set rstMetrics = qdfMetrics.OpenRecordset(dbReadOnly)
> 6.        varResults = rstMetrics.GetRows(rstMetrics.RecordCount)
> 7.        Set objXLBook = GetObject(cXLPath & cXLFile)
> 8.        Set objXLApp = objXLBook.Parent
> 9.        Set objQuerySheet = objXLBook.Worksheets("ProductMetrics")
> 10.      objXLApp.Visible = True
> 11.      objXLBook.Windows(1).Visible = True
> 12.      Set objXLRange = objQuerySheet.Range("B1:G4")
> 13.      objXLRange.FormulaArray = varResults
> 
> Mark Mitsules

<SNIP>



More information about the AccessD mailing list