PC Review


Reply
Thread Tools Rate Thread

Between And in SQL Statement

 
 
Linda
Guest
Posts: n/a
 
      16th Apr 2004
I,m using the following statment to limit my recordset:

Dim vardatebeg, vardateend as variant

Set rstin = dbs.OpenRecordset("Select * From tblAllDates
Where CallDate Between #varDateBeg# And #varDateEnd#")

When debugging I,m getting the follwing error message:

syntax error in date in query expression.
Can anyone see what I'm doing wrong here? TIA

 
Reply With Quote
 
 
 
 
Ken Snell
Guest
Posts: n/a
 
      16th Apr 2004
Assuming that varDateBeg and varDateEnd are variables, concatenate their
values into the string outside the string:

Set rstin = dbs.OpenRecordset("Select * From tblAllDates Where CallDate
Between #" & varDateBeg & "# And #" & varDateEnd & "#")


--
Ken Snell
<MS ACCESS MVP>

"Linda" <(E-Mail Removed)> wrote in message
news:005301c423ed$e3887a10$(E-Mail Removed)...
> I,m using the following statment to limit my recordset:
>
> Dim vardatebeg, vardateend as variant
>
> Set rstin = dbs.OpenRecordset("Select * From tblAllDates
> Where CallDate Between #varDateBeg# And #varDateEnd#")
>
> When debugging I,m getting the follwing error message:
>
> syntax error in date in query expression.
> Can anyone see what I'm doing wrong here? TIA
>



 
Reply With Quote
 
Phil Hunt
Guest
Posts: n/a
 
      16th Apr 2004
try copy and paste the following, basically you need to suround the dates
with quoute
Set rstin = dbs.OpenRecordset("Select * From tblAllDates
Where CallDate Between #" & varDateBeg & "# And #" & varDateEnd & "#")

"Linda" <(E-Mail Removed)> wrote in message
news:005301c423ed$e3887a10$(E-Mail Removed)...
> I,m using the following statment to limit my recordset:
>
> Dim vardatebeg, vardateend as variant
>
> Set rstin = dbs.OpenRecordset("Select * From tblAllDates
> Where CallDate Between #varDateBeg# And #varDateEnd#")
>
> When debugging I,m getting the follwing error message:
>
> syntax error in date in query expression.
> Can anyone see what I'm doing wrong here? TIA
>



 
Reply With Quote
 
Guest
Posts: n/a
 
      16th Apr 2004
Thanks guys!!
>-----Original Message-----
>Assuming that varDateBeg and varDateEnd are variables,

concatenate their
>values into the string outside the string:
>
>Set rstin = dbs.OpenRecordset("Select * From tblAllDates

Where CallDate
>Between #" & varDateBeg & "# And #" & varDateEnd & "#")
>
>
>--
> Ken Snell
><MS ACCESS MVP>
>
>"Linda" <(E-Mail Removed)> wrote in

message
>news:005301c423ed$e3887a10$(E-Mail Removed)...
>> I,m using the following statment to limit my recordset:
>>
>> Dim vardatebeg, vardateend as variant
>>
>> Set rstin = dbs.OpenRecordset("Select * From

tblAllDates
>> Where CallDate Between #varDateBeg# And #varDateEnd#")
>>
>> When debugging I,m getting the follwing error message:
>>
>> syntax error in date in query expression.
>> Can anyone see what I'm doing wrong here? TIA
>>

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reconcile Bank statement & Credit card statement & accounting data Bklynhyc Microsoft Excel Worksheet Functions 0 7th Oct 2009 10:07 PM
select statement into if statement in an event code (syntax error =?Utf-8?B?dG90YQ==?= Microsoft Access VBA Modules 1 12th Dec 2004 12:13 PM
Dlookup function in a SQL Statement giving Error Expected: End of Statement Edward S Microsoft Access 1 19th May 2004 03:41 AM
Dlookup function in a SQL Statement giving Error Expected: End of Statement Edward S Microsoft Access 1 17th May 2004 09:34 PM
How to chart a profit & loss statement/Profitability analysis statement in Excel Charts Belinda Microsoft Excel Charting 3 3rd May 2004 10:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:32 PM.