How do I add Parenthesis and a or in delphi code to a reports search
This is what I currently have
CreateAutoSearchCriteria('begin','',soLike,'',False); **
CreateAutoSearchCriteria('SVS_TARGET','MAINTAINED',soBetween,'01/01/2005,31/01/2005',FALSE);
AutoSearchFields[0].SearchExpression := RepMonthRange;
CreateAutoSearchCriteria('OR','',soLike,'',False); **
CreateAutoSearchCriteria('SVS_TARGET','NO
ACCESS',soBetween,'01/01/2005,31/01/2005',FALSE);
AutoSearchFields[0].SearchExpression := RepMonthRange;
CreateAutoSearchCriteria('end','',soLike,'',False); **
CreateAutoSearchCriteria('SVS_TARGET','MSYSTEM', soInList,'I',FALSE);
AutoSearchFields[1].SearchExpression := RepSystem;
I would like the rb sql to read
where
(Maintained is between RepMonthRange OR NoAccess is between RepmonthRange)
and MSystem = RepSystem.
All is well but its the adding of the begin, end and OR that are giving me
the trouble (please see the lines marked with **)
Many thanks
Antony
CreateAutoSearchCriteria('begin','',soLike,'',False); **
CreateAutoSearchCriteria('SVS_TARGET','MAINTAINED',soBetween,'01/01/2005,31/01/2005',FALSE);
AutoSearchFields[0].SearchExpression := RepMonthRange;
CreateAutoSearchCriteria('OR','',soLike,'',False); **
CreateAutoSearchCriteria('SVS_TARGET','NO
ACCESS',soBetween,'01/01/2005,31/01/2005',FALSE);
AutoSearchFields[0].SearchExpression := RepMonthRange;
CreateAutoSearchCriteria('end','',soLike,'',False); **
CreateAutoSearchCriteria('SVS_TARGET','MSYSTEM', soInList,'I',FALSE);
AutoSearchFields[1].SearchExpression := RepSystem;
I would like the rb sql to read
where
(Maintained is between RepMonthRange OR NoAccess is between RepmonthRange)
and MSystem = RepSystem.
All is well but its the adding of the begin, end and OR that are giving me
the trouble (please see the lines marked with **)
Many thanks
Antony
This discussion has been closed.
Comments
Rather than creating your search criteria using the CreateAutoSearchCriter
routing, a much easier approach would be to use the TdaSQLBuilder class.
This gives you a number of easy-to-use routines that allow you to alter the
SQL object and add search criteria to your DADE dataviews.
Take a look at the TdaSQLBuilder and TdaSQLCriteriaList topics in the
ReportBuilder help. This will give you an idea how to accomplish what you
need and includes some code example on creating your own search criteria.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
(CreateAutoSearchCriteria) I only want to do it this one time ?
Thanks
Antony
The Report.CreateAutoSearchCriteria does not give you the ability to add
criteria types to your search condition. This is why we added the
TdaSQLBuilder class. Creating an autosearch criteria is very simple using
the TdaSQLBuilder object...
Psuedo Code...
lSQLBuilder := TdaSQLBuilder.Create(Report.DataPipeline);
lSQLBuilder.Clear;
lSQLBuilder.SelectTables.Add('MyTable');
lSQLBuilder.SelectFields.AddAllFields;
lSQLBuilder.SearchCriteria.InsertOpenParentheses(lSQLBuilder.SearchCriteria.Count);
lSQLBuilder.SearchCriteria.AddAutoSearch('MyTable', 'MyField', 'Like',
'S');
lSQLBuilder.SearchCriteria.InsertCloseParentheses(lSQLBuilder.SearchCriteria.Count);
lSQLBuilder.SearchCriteria.InsertOr(lSQLBuilder.SearchCriteria.Count);
lSQLBuilder.SearchCriteria.InsertOpenParentheses(lSQLBuilder.SearchCriteria.Count);
lSQLBuilder.SearchCriteria.AddAutoSearch('MyTable', 'MyField', 'Like',
'G');
lSQLBuilder.SearchCriteria.InsertCloseParentheses(lSQLBuilder.SearchCriteria.Count);
lSQLBuilder.ApplyUpdates;
lSQLBuilder.Free;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com