|
-
Feb 21st, 2001, 09:41 AM
#1
Thread Starter
New Member
Dear All
I was wondering whether anyone could help.
How come when I hard code in the selection formula it works fine but when I build the selection formula via a string it fails to launch the Crystal report window and work.
I have checked the string and it gives the EXACT syntax as the hard coding. Still it doesn't work.
I am at a loss as to why it doesn't work - Suggestions please.
Below is an example of my code. The string is built on the contents of a list box. Code is best viewed in 'Courier font' as I'm sure you'll already know.
Dim frmcount As Integer
Dim frmloop As Integer
Dim result As String
frmcount = List1.ListCount - 1
result = Chr(34) & "{query.lot_number}='"
For frmloop = 0 To frmcount
result = result & List1.List(frmloop) & "'"
If frmloop <> frmcount Then result = result & " or {query.lot_number}='"
Next frmloop
result = result & Chr(34)
RecallReport.SelectionFormula = result
RecallReport.PrintReport
Cheers
Stewart
-
Feb 21st, 2001, 10:26 AM
#2
Lively Member
Quotes and stuff
I believe the CHR(34) wrapping you have is unnecessary.
This works fine for me:
Code:
Report.RecordSelectionFormula = "{tempreport.reportid}=" & miReportID
I fink you'd need to amend it slightly for a string
Code:
Report.RecordSelectionFormula = "{tempreport.reportid}='" & msReportID & "'"
just add a single quote around the string to compare.
This may help, praps not..... I'm not a great fan of Crystal it has to be said, if I can delegate the report stuff then I usually do!
Anakim
It's a small world but I wouldn't like to paint it.
-
Feb 21st, 2001, 12:46 PM
#3
Thread Starter
New Member
HELLO
Because my criteria comes from a listbox then my selectionformula needs to be dynamic.
Therefore I cannot simply use.
RecallReport.SelectionFormula = "{query.lot_number}='" & ID & "'"
My string builds to include the ' or ' statement.
Example.
Listbox user selection = "A" and "B"
Then my SelectionFormula = "{query.lot_number}='A' or {query.lot_number}='B'"
If I hard code this in it works, but I can't because I cant restrict the user to a number of selections. I can build this SelectionFormula (string) via code (as I have done) so that it is exactly the same as the hard code but it fails to work.
I have to include the Chr(34) to make the string EXACTLY like the hard code.
I find it hard to understand why the hard code version works, but the string doesn't. Even though the syntax is EXACTLY the same.
Please help if you can.
Stewart
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|