Re: Parameter Data Type Problem



If you open the query in design view, are the parameters declared?
Choose Parameters on Query menu, and enter 2 rows in the dialog, e.g.:
[Forms].[Form1].[txtStartDate] Date/Time
[Forms].[Form1].[txtEndDate] Date/Time
Additionally, set the Format property of the 2 text boxes so Access knows
they are dates on the form as well.

An alternative approach is to lose the saved query and just build the SQL
string:
Dim strSql As String
Const strcJetDate = "\#mm\/dd\/yyyy\#"
With Forms!Form1
If IsDate(!txtStartDate) And IsDate(!txtEndDate) Then
strSql = "SELECT ... WHERE ([MyDate] Between " & _
Format(!txtStartDate, strcJetDate) & " And " & _
Format(!txtEndDate, strcJetDate) & ");"
Set rst = db.OpenRecordset(strSql)
...
End If
End With

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"BillCo" <coleman.bill@xxxxxxxxx> wrote in message
news:1151655487.978510.287550@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

A2000, DAO 3.6 ref set, 2 Parameters in query from an unbound form.

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim qryDef As DAO.QueryDef
Dim prm As DAO.Parameter

Set db = CurrentDb
Set qryDef = db.QueryDefs("qryWeeklyCreditClass")

For Each prm In qryDef.Parameters
prm = Eval(prm.Name)
Next

Set rst = qryDef.OpenRecordset <========== Breaks here (3464,
Data Type mismatch)

I have two *possible* reasons:
1. Query references several sub queries, each of which also reference
the form parameters
2. Parameters are dates. I've tried concatonating "#"s, and using
cdate() but no joy

Needless to say, the query runs fine normally.

Anyone know why this is happening or how to get around it? Starting to
lose the plot on this one!!!


.



Relevant Pages

  • Re: ADODB Recordset Not Loading From Parameter Query
    ... The query itself runs fine when running manually and supplying the ... Dim con As ADODB.Connection ... Dim prm As ADODB.Parameter ... Set prm = cmd.CreateParameter("@LastName", adVarChar, adParamInput, 25) ...
    (microsoft.public.access.modulesdaovba)
  • RE: Breaking down imported information
    ... Single-record append query: ... ' Check if at EOF of Recordset (rsDataViaCode) ... ' if at EOF Exit Do. ... Dim rsDataViaCode As DAO.Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: LDAP query information
    ... Copyright 1985-2001 Microsoft Corp. ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... Set adoConnection = CreateObject ... ' Construct LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Re: LDAP query information
    ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... Set adoConnection = CreateObject ... ' Construct LDAP syntax query. ... Yes, the script uses ADO to query AD directly, which is very efficient - no ...
    (microsoft.public.windows.server.scripting)
  • Re: OpenRecordset
    ... query is taking values or criteria from fields on a form (which are treated ... Dim qdf As DAO.QueryDef ... Dim prm As DAO.Parameter ...
    (microsoft.public.access.formscoding)