Solved

Wanted: VB SQL Expert

Posted on 2000-03-17
11
185 Views
Last Modified: 2010-05-02
Please step up to the plate,
I want to allow users to enter the reporting period( date to date) for a Crystal Reports Active X comp. ver 6. using a dialogue form to pass a sql query via a string argument.

 The sql for crystal reports is slightly different than vb sql, so my books are not helping.

I am using the Record Selection Formula Editor(Crystal Reports), to enter the following formula:
"{ClientInteraction.Date_Interaction} in "  &  txt_FromDate.Text &    "  to  " & txt_ToDate.Text
---------------------------------------
the report is displayed in a vb form via a CRViewer1 object.

The editor generates an error:
"The remaining text does not appear to be part of the formula" , it places the cursor --> &  txt_FromDate.Text &    "  to  " & txt_ToDate.Text
=======================================
Thank you.

0
Comment
Question by:diek_nf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 9

Expert Comment

by:Dalin
ID: 2627732
Try:
"{ClientInteraction.Date_Interaction} in' "  &  txt_FromDate.Text &    "'  to ' " & txt_ToDate.Text  & "' "
0
 
LVL 2

Expert Comment

by:brice123
ID: 2627817
If you really want to be independant from your regional settings, use the
following statement :

"{Acts.PublishingDate} = Date (2000, 12, 31)"



0
 
LVL 2

Accepted Solution

by:
brice123 earned 60 total points
ID: 2627849
In your case, the code could be :

(I assume that your arguments are stored in two date variables, dtmFrom and dtmTo)

strFormula = "{ClientInteraction.Date_Interaction} >= Date(" & Year(dtmFrom) & "," & Month(dtmFrom) & "," & Day(dtmFrom) & ") And {ClientInteraction.Date_Interaction} <= Date(" & Year(dtmTo) & "," & Month(dtmTo) & "," & Day(dtmTo) & ")"

crViewer.SelectionFormula = strFormula
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:diek_nf
ID: 2627918
Brice123,
Please don't get pissed, like some other guy after I rejected his answer. First, I am uncertain what region settings have to do with users entering two dates.

Second,your other answer may work but when you answer a question, as opposed to commenting, you lock the question until I evaluate it. I will try your second comment. Again please do not get mad.
diek
0
 
LVL 1

Expert Comment

by:prozak
ID: 2627997
What database are you using? In most databases you have to put special characters around a date constant in an SQL statement. In access you use the "#" (pound) sign, in DB2 you use a single quote. I would try formatting the date and wrapping it.

"{ClientInteraction.Date_Interaction} in #" & Format(txt_FromDate.Text, "MM/DD/YYYY") & "#  to #" & Format(txt_ToDate.Text, "MM/DD/YYYY") & "#"

The pound sign may not be the correct character for your DBMS but I think you get the idea.


0
 

Author Comment

by:diek_nf
ID: 2628081
prozak and others,
I got to work on another area for a few hours so I won't have the chance to try your comments until later today. I will try everyones code. I'll be back. Thanks.
diek
0
 
LVL 2

Expert Comment

by:brice123
ID: 2634970
diek,

I definitively recommend to use the next syntax. You will be independant from the date format used by the underlying database.

dim dtmFrom as date
dim dtmTo as date
dim strFormula as string

if IsDate(txt_FromDate) then
  dtmFrom = CDate(txt_FromDate)
end if

if IsDate(txt_ToDate) then
  dtmTo = CDate(txt_ToDate)
end if

strFormula = "{ClientInteraction.Date_Interaction} in Date(" & Year(dtmFrom) & "," & Month(dtmFrom) & "," & Day(dtmFrom) & ") to Date(" & Year(dtmTo) & "," & Month(dtmTo) & "," & Day(dtmTo) & ")"

crViewer1.SelectionFormula=strFormula
0
 

Author Comment

by:diek_nf
ID: 2636280
Brice,
I am passing the strFormula as a global and I know it is getting passed to my the form with my crviewer, as {ClientInteraction.Date_Interaction} in Date(14,3,1960) to Date(30,12,1999). Through a Msgbox asa tes.

 It still isn't restricting the dates however.

Thanks for not getting pissed when I rejected your last note , how would I get:
"{Acts.PublishingDate} = Date (2000, 12, 31)"
to display Dec as opposed to 12.
0
 

Author Comment

by:diek_nf
ID: 2637687
Brice,
I am only doing this to unlock the question and because that didn't work.
diek
0
 

Author Comment

by:diek_nf
ID: 2680802
Hi,
if anyone is still interested I am still in need of assistance.
diek
0
 

Author Comment

by:diek_nf
ID: 2682021
I revisited this solution and it worked. Thank you.
diek
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month6 days, 8 hours left to enroll

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question