Passing Date Parameters to Access Query

Results 1 to 2 of 2

Thread: Passing Date Parameters to Access Query

  1. #1
    Join Date
    Dec 1969

    Default Passing Date Parameters to Access Query

    I&#039m trying to pass a date parameter from a text field to an Access query, but when I keep getting the following error:<BR>"Microsoft JET Database Engine error &#039 80040e07 Data type mismatch in criteria expression&#039". I&#039ve tested the variable using TypeName(), and it tests as dates. I think it has something to do with the &#039#&#039 sign that Access puts in front of and behind dates, but when I try to use them my data type changes to String and I get an error. Does anyone know what I&#039m doing wrong? Here&#039s the relevant code:<BR><BR>Dim startDate<BR>Dim myObject<BR>Dim myRS<BR>Dim objParam1<BR><BR>startDate = cDate(Request.Form("T1"))<BR><BR>set myobject = server.CreateObject("ADODB.Command")<BR><BR>myObje ct.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0; " & _<BR> "Data Source=C:BillingBilling.mdb; " & _<BR> "Persist Security Info = False"<BR><BR>myObject.CommandText = "CustomerHoursbyPayType"<BR>myObject.CommandTy pe = adCmdStoredProc<BR><BR>Set objParam1 = myObject.CreateParameter("theStartDate",adDate, adParamInput,50)<BR><BR>myObject.Parameters.Append objParam1<BR><BR>myObject.Parameters("theStartDate ") = startDate<BR><BR>Set myRS = myObject.Execute &#039This is where I get the error!<BR>

  2. #2
    asphead Guest

    Default RE: Passing Date Parameters to Access Query

    Try:<BR><BR>myObject.Parameters("theStartDate") = cDate(startDate)<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts