QueryDef

G

Guest

Sorry to post this twice (also in Programming VBA) but I think it belongs here

I am calling zReport1 from Form1. The Report has the
following recordset code :

Dim db1 As Databas
Dim rs As Recordse
Dim qdf As QueryDe
Dim prm As Paramete

Set db1 = CurrentD

Set qdf = db1.QueryDefs("Query1"

For Each prm In qdf.Parameter
prm.Value = Eval(prm.Name
Next pr

Set rs = qdf.OpenRecordset(dbOpenDynaset

''''

Query1 pulls back few fields from some tables and one of
the fields, a date format field, has the ctriteria :

Between [Forms]![Form1].[Combo2] And [Forms]![Form1]
[Combo2]+

Combo2 on Form1 is a simple list of dates in date format

The code above fails at :

Set rs = qdf.OpenRecordset(dbOpenDynaset

with an error about incompatible data types

If I change the query criteria to Between Date() and Dat
()+6 (i.e. using system clock rather than combo list) it
works O

Any ideas?
 
G

Graham Mandeno

Hi Andy

The combo box value is actually returning a string, which Access is clever
enough to evaluate when the query is opened from the database window.
However, when you open it from VBA it fails to do this.

Try this:
Between CDate([Forms]![Form1].[Combo2]) And
CDate([Forms]![Form1].[Combo2])+6
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top