Re: QueryDef
From: Graham Mandeno (Graham.Mandeno_at_nomail.please)
Date: 05/11/04
- Next message: Graham Mandeno: "Re: Scroll madness. Please heeeeellllllp."
- Previous message: Graham Mandeno: "Re: getting rid of helpbox on menubar"
- In reply to: Andy: "QueryDef"
- Next in thread: Andy: "Re: QueryDef"
- Reply: Andy: "Re: QueryDef"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 11 May 2004 23:41:10 +1200
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
--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand
"Andy" <anonymous@discussions.microsoft.com> wrote in message
news:6CDD0B1D-7A8B-4157-BB46-ECB1D601EC1A@microsoft.com...
> 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 Database
> Dim rs As Recordset
> Dim qdf As QueryDef
> Dim prm As Parameter
>
> Set db1 = CurrentDb
>
> Set qdf = db1.QueryDefs("Query1")
>
> For Each prm In qdf.Parameters
> prm.Value = Eval(prm.Name)
> Next prm
>
> 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]+6
>
> 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 Date
> ()+6 (i.e. using system clock rather than combo list) it
> works OK
>
> Any ideas?
>
>
- Next message: Graham Mandeno: "Re: Scroll madness. Please heeeeellllllp."
- Previous message: Graham Mandeno: "Re: getting rid of helpbox on menubar"
- In reply to: Andy: "QueryDef"
- Next in thread: Andy: "Re: QueryDef"
- Reply: Andy: "Re: QueryDef"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|