Results 1 to 5 of 5

Thread: Any idea why this code for Crystal Reports won't work with Strings?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    Austin,TX,USA
    Posts
    98
    Do any of the Crystal Report gurus know why this works with an Integer but NOT when it's a String?

    Dim TestNum As Integer
    SurNum = 1
    Dim TestName As String
    SurName = "This is Report Style # 2!"

    With Report1
    .CrystalReport1.DataFiles(0) = App.Path & "\test.mdb"
    .CrystalReport1.ReportFileName = "\latest.rpt"
    .CrystalReport1.Formulas(0) = "startcode = " & TestNum
    .CrystalReport1.Action = 1
    End With

    This will work with TestNum but I get "Error in Formula" if I try it with TestName(a string). Any ideas why? What I'm trying to do is pass the Test Name as a Page Header to the Crystal Report report? ANY help would be greatly appreciated!

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    When you want to use report style #2, try this syntax:
    Code:
    .CrystalReport1.Formulas(0) = "startcode = '" & SurName & "'"
    "It's cold gin time again ..."

    Check out my website here.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    Austin,TX,USA
    Posts
    98
    Wow! Thank you both! Scott, I'll remember your advice, BruceG your code worked like a charm! Thanks guys!

  4. #4
    Guest
    What's Crystal Reprts used for?

  5. #5
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Thom: Glad to be of service.
    Sc0rp: CR is used mostly to give VB reporting capabilities for VB database apps (similar to the report-writing feature of Access).
    "It's cold gin time again ..."

    Check out my website here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width