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
Solved

Crystol Reports Selection Formula

Posted on 1997-10-12
4
288 Views
Last Modified: 2012-08-14
I want to set the data selection criteria in VB (ie not within Crystol Reports). The following code gives an "Error in formula" message:

Report1.SelectionFormula = "[ContactRef]='Client'"

Can you help please.
0
Comment
Question by:ncw
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:haas090897
ID: 1437321
The syntax for Selectionformula is {tablename.field}='value', in your case you use the wrong bracket type around the table.field clause. If you are not sure about the syntax try using Crystal report and edit the formula in the Record Selection formula Editor. You will be able to check the syntax at once by the Check button. When you are finished you just cut and paste to vb, replace the value by a dynamic value.
The code would look something like this:
Report1.SelectionFormula = "{tablename.field}='" szVariable & "'"
Hope this would help.
0
 
LVL 1

Author Comment

by:ncw
ID: 1437322
I have cut and pasted your code into the program, replacing your text as follows:

Report1.SelectionFormula = "{Contacts.ContactRef}='"Client"'"

but this gives the 'Expected end of statement' message.

I've tried altering the combination of " and ' without success.

Should this code form part of a query SQL?

0
 
LVL 1

Accepted Solution

by:
haas090897 earned 100 total points
ID: 1437323
The word client should not be between ", in your case the formula would look like this:
Report1.SelectionFormula="{Contacts.ContactRef}='Client'" or

dim myVariable  as string
myVariable="Client" 'This value may be altered

Report1.SelectionFormula="{Contacts.ContactRef}='" & 
myvariable & "'"
or why not like this:
dim myVariable  as string
myVariable="{Contacts.ContactRef}='Client'" 'This value may be altered

Report1.SelectionFormula=myvariable
The main thing is that textvalues in formulas must be enclosed
by ' '.

Look at your code and count the ", after the second " the string is terminated, to continue the string you need to set the & 
after the ", and so on. Easy string manipulation.

In the first answere even i missed the &, sorry.
Better luck this time!
0
 
LVL 1

Author Comment

by:ncw
ID: 1437324
Yes, i've got that to work now, thank you.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

808 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