Dim dtDay1 As Date
Dim dtDay2 As Date
Dim dtDay3 As Date
'once working I'll load these variables from a multi listbox.
dtDay1 = #7/22/2007#
dtDay2 = #7/24/2007#
dtDay3 = #7/25/2007#
This works:
DoCmd.OpenReport "frmTest", acViewPreview, , "[Weekend_Date] = " & "#"
& dtDay1 & "#"
This does not work:
DoCmd.OpenReport "frmTest", acViewPreview, , "[Weekend_Date] = " & "#"
& dtDay1 & "#" Or "[Weekend_Date] = " & "#" & dtDay2 & "#" Or
"[Weekend_Date] = " & "#" & dtDay3 & "#"
I get a type mismatch error but I think its poor syntax in the Where
Clause. Probably the quotes againnnnnnnn.
RICK 4 1379
On Wed, 18 Jul 2007 13:31:37 -0700, 2D Rick <rb*******@compuserve.com>
wrote:
The WHERE argument needs to be a single string.
-Tom.
>Dim dtDay1 As Date Dim dtDay2 As Date Dim dtDay3 As Date
'once working I'll load these variables from a multi listbox. dtDay1 = #7/22/2007# dtDay2 = #7/24/2007# dtDay3 = #7/25/2007#
This works: DoCmd.OpenReport "frmTest", acViewPreview, , "[Weekend_Date] = " & "#" & dtDay1 & "#"
This does not work: DoCmd.OpenReport "frmTest", acViewPreview, , "[Weekend_Date] = " & "#" & dtDay1 & "#" Or "[Weekend_Date] = " & "#" & dtDay2 & "#" Or "[Weekend_Date] = " & "#" & dtDay3 & "#"
I get a type mismatch error but I think its poor syntax in the Where Clause. Probably the quotes againnnnnnnn.
RICK
Simple answer: use IN in your criteria clause...it will look something like
this:
DoCmd.OpenReport "frmTest", acViewPreview, , "[Weekend_Date] IN (#" & dtDay1
& "#, #" & dtDay2 & "#,#" & dtDay3 & "#)"
But if you're using values from a listbox, you're probably wasting your time
trying to assign them to variables. What if the user only chooses one date?
Or chooses five? It's probably better to build the criteria clause
dynamically as you loop through the ItemsSelected collection of the list
box.
*air code*
strCriteria = "[Weekend_Date] IN (#"
With Me.lstMyDates
For each varItem in .ItemsSelected
strCriteria = strCriteria & CStr(.Column(0, varItem)) & "#,#"
' above assumes date is the bound listbox column - adjust as
necessary
Next varItem
End With
strCriteria = Left$(strCriteria, Len(strCriteria)-2)
DoCmd.OpenReport "frmTest", acViewPreview, , strCriteria
"Tom van Stiphout" <no*************@cox.netwrote in message
news:fk********************************@4ax.com...
On Wed, 18 Jul 2007 13:31:37 -0700, 2D Rick <rb*******@compuserve.com>
wrote:
The WHERE argument needs to be a single string.
-Tom.
>>Dim dtDay1 As Date Dim dtDay2 As Date Dim dtDay3 As Date
'once working I'll load these variables from a multi listbox. dtDay1 = #7/22/2007# dtDay2 = #7/24/2007# dtDay3 = #7/25/2007#
This works: DoCmd.OpenReport "frmTest", acViewPreview, , "[Weekend_Date] = " & "#" & dtDay1 & "#"
This does not work: DoCmd.OpenReport "frmTest", acViewPreview, , "[Weekend_Date] = " & "#" & dtDay1 & "#" Or "[Weekend_Date] = " & "#" & dtDay2 & "#" Or "[Weekend_Date] = " & "#" & dtDay3 & "#"
I get a type mismatch error but I think its poor syntax in the Where Clause. Probably the quotes againnnnnnnn.
RICK
You just got your quotes fuzzulated:
DoCmd.OpenReport "frmTest", acViewPreview, , "(([Weekend_Date] = #"
& dtDay1 & "#) OR ([Weekend_Date] = #" & dtDay2 & "#) OR
([Weekend_Date] = #" & dtDay3 & "#))"
remember that what you are doing is wrapping the text strings around
the values contained in your variables...
btw...I like parenthethezez...
Ron, King of Chi
On Jul 18, 3:31 pm, 2D Rick <rbrown...@compuserve.comwrote:
Dim dtDay1 As Date
Dim dtDay2 As Date
Dim dtDay3 As Date
'once working I'll load these variables from a multi listbox.
dtDay1 = #7/22/2007#
dtDay2 = #7/24/2007#
dtDay3 = #7/25/2007#
This works:
DoCmd.OpenReport "frmTest", acViewPreview, , "[Weekend_Date] = " & "#"
& dtDay1 & "#"
This does not work:
DoCmd.OpenReport "frmTest", acViewPreview, , "[Weekend_Date] = " & "#"
& dtDay1 & "#" Or "[Weekend_Date] = " & "#" & dtDay2 & "#" Or
"[Weekend_Date] = " & "#" & dtDay3 & "#"
I get a type mismatch error but I think its poor syntax in the Where
Clause. Probably the quotes againnnnnnnn.
RICK
Great solution! I kept forgetting about the 'IN' and have any times
scratched my head thinking how am I going to do this...... :)
bobh.
On Jul 19, 1:42 am, "RMCEU1" <robemce...@hotmail.comwrote:
Simple answer: use IN in your criteria clause...it will look something like
this:
DoCmd.OpenReport "frmTest", acViewPreview, , "[Weekend_Date] IN (#" & dtDay1
& "#, #" & dtDay2 & "#,#" & dtDay3 & "#)"
But if you're using values from a listbox, you're probably wasting your time
trying to assign them to variables. What if the user only chooses one date?
Or chooses five? It's probably better to build the criteria clause
dynamically as you loop through the ItemsSelected collection of the list
box.
*air code*
strCriteria = "[Weekend_Date] IN (#"
With Me.lstMyDates
For each varItem in .ItemsSelected
strCriteria = strCriteria & CStr(.Column(0, varItem)) & "#,#"
' above assumes date is the bound listbox column - adjust as
necessary
Next varItem
End With
strCriteria = Left$(strCriteria, Len(strCriteria)-2)
DoCmd.OpenReport "frmTest", acViewPreview, , strCriteria
"Tom van Stiphout" <no.spam.tom7...@cox.netwrote in messagenews:fk********************************@4ax .com...
On Wed, 18 Jul 2007 13:31:37 -0700, 2D Rick <rbrown...@compuserve.com>
wrote:
The WHERE argument needs to be a single string.
-Tom.
>Dim dtDay1 As Date Dim dtDay2 As Date Dim dtDay3 As Date
>'once working I'll load these variables from a multi listbox. dtDay1 = #7/22/2007# dtDay2 = #7/24/2007# dtDay3 = #7/25/2007#
>This works: DoCmd.OpenReport "frmTest", acViewPreview, , "[Weekend_Date] = " & "#" & dtDay1 & "#"
>This does not work: DoCmd.OpenReport "frmTest", acViewPreview, , "[Weekend_Date] = " & "#" & dtDay1 & "#" Or "[Weekend_Date] = " & "#" & dtDay2 & "#" Or "[Weekend_Date] = " & "#" & dtDay3 & "#"
>I get a type mismatch error but I think its poor syntax in the Where Clause. Probably the quotes againnnnnnnn.
>RICK- Hide quoted text -
- Show quoted text -
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Blah Blah |
last post by:
i just thought i'd shoot out a quick email on problems i've been having with
utf-8 in moving from 4.1.0 to 4.1.1. (please note that because i am using
UTF-8 as my default character set, i compiled...
|
by: saracen44 |
last post by:
Hi
I have MyISAM tables
When I'm deleting parent I want to delete children in the same time.
How can I do It? What are possibilities?
Thanks
|
by: John Rivers |
last post by:
hi, here is how to do it and restore sanity to aspx html rendering:
(please only reply with sensible architectural discussion - juan)
put this at the end of an aspx file (or use an include at...
|
by: Alan Foxmore |
last post by:
Hi everyone,
I'm new to C# and I was hoping I could get some clarification on the
syntax for jagged and multidimensional arrays.
Here is my question:
The following syntax is correct for...
|
by: Terry C. |
last post by:
I have a bit of code that loops through a listbox and creates a string of
multiple selections and then passes that string to a SQL statement. However,
I cannot seem to get a handle on the proper...
|
by: Olly |
last post by:
Hello Everyone!
Could someone please have a look at my JS Form I posted
below....Something wrong there, but I don't understand what's exactly.
Many thanks.
Olly
...
|
by: Bruce W. Darby |
last post by:
This will be my very first VB.Net application and it's pretty simple. But
I've got a snag in my syntax somewhere. Was hoping that someone could point
me in the right direction.
The history:
My...
|
by: animatix |
last post by:
this is how far i have gotten.
<pathtoslides>www.animatix.us/slides/multi/VAR PIC</pathtoslides>
<pathtoproj> pop up path to fullproj, syntax flash to trigger embedded javascript to load new...
|
by: BruceWho |
last post by:
I downloaded boost1.35.0 and built it with following command:
bjam --toolset=msvc-7.1 --variant=release --threading=multi --
link=shared --with-system stage
and it failed to compile, error...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |