Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Do.Cmd.OpenReport Where Condition Problem

105 views
Skip to first unread message

Wally Davenport

unread,
Nov 29, 1999, 3:00:00 AM11/29/99
to
In Access 2000 I am having a problem with the 'Where Condition' for the DoCmd.OpenReport...... below show as Bold
It reports a RunTime Error 13 Type Mismatch
If I remove the 'strWhere AND' , no error
If I leave just the 'strWhere' in, no error

Could someone please give the right syntax?

SAMPLE CODE
Dim varItem As Variant
Dim strWhere As String
Dim ctl As Control
strWhere = "[Name] in("
Set ctl = Me![List1]
For Each varItem In ctl.ItemsSelected
    strWhere = strWhere & Chr$(34) & ctl.ItemData(varItem) & Chr$(34) & ","
Next
strWhere = Left$(strWhere, Len(strWhere) - 1) & ")"

DoCmd.OpenReport "rpt1", acViewPreview, , strWhere And "[Date] Between Forms![frmSearchLoadByOwner]![StartDate] And Forms![frmSearchLoadByOwner]![EndDate]"

Thanks
Wally

fredg

unread,
Nov 29, 1999, 3:00:00 AM11/29/99
to
Hi Wally,
What's one & more or less?
Did you try:

DoCmd.OpenReport "rpt1", acViewPreview, , strWhere & " And [Date] Between


Forms![frmSearchLoadByOwner]![StartDate] And
Forms![frmSearchLoadByOwner]![EndDate]"

Fred

Wally Davenport <wa...@dryden.net> wrote in message
news:38421983...@dryden.net...

Michael Jozwik

unread,
Nov 29, 1999, 3:00:00 AM11/29/99
to
Wally,
Try:
DoCmd.OpenReport "rpt1", acViewPreview, , strWhere & " And [Date] Between Forms![frmSearchLoadByOwner]![StartDate] And Forms![frmSearchLoadByOwner]![EndDate]"
 
Instead of:
DoCmd.OpenReport "rpt1", acViewPreview, , strWhere And "[Date] Between Forms![frmSearchLoadByOwner]![StartDate] And Forms![frmSearchLoadByOwner]![EndDate]"
 

--
Cheers,
 
Michael Jozwik
JAM Data Services, Inc. ( http://www.jamdata.net )
mi...@jamdata.net

Wally Davenport

unread,
Nov 29, 1999, 3:00:00 AM11/29/99
to
Thanks Fred and Michael

Your suggestion works just fine. I am a newbe at this and I never thought of
trying it that way.
Until my next problem

Wally


fredg wrote:

> Hi Wally,
> What's one & more or less?
> Did you try:
>

> DoCmd.OpenReport "rpt1", acViewPreview, , strWhere & " And [Date] Between
> Forms![frmSearchLoadByOwner]![StartDate] And
> Forms![frmSearchLoadByOwner]![EndDate]"
>

> Fred

0 new messages