Results 1 to 3 of 3

Thread: Simple way for Crystal Report Code in Vb6

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2021
    Posts
    1

    Simple way for Crystal Report Code in Vb6

    Dear All,
    I have a problem with Crystal Report 8.0 Code on VB6,
    please help me how to simple my code,
    this is my code :
    Private Sub cmdPrint_Click()
    If Text1.Text = "" Then
    MsgBox ("PO Number cannot be Blank..")
    ElseIf Text2.Text = "" Then
    PrintPO1
    Else
    If Text3.Text <> "" Then
    PrintPO3
    Else
    PrintPO2
    End If
    End If
    End Sub
    Sub PrintPO1()
    With CRT
    .Connect = "dsn=192.168.0.2;uid=sa;pwd=sa123sa;dsq=iats"
    .ReportFileName = App.Path & "\PO.rpt"
    .DiscardSavedData = True
    .SelectionFormula = "totext ({TRPOH.PONo}) ='" & Text1.Text & "'"
    .RetrieveDataFiles
    .SortFields(0) = "+{TRPOD.SortNumber}"
    .Action = 1
    End With
    End Sub
    Sub PrintPO2()
    With CRT
    .Connect = "dsn=192.168.0.2;uid=sa;pwd=sa123sa;dsq=iats"
    .ReportFileName = App.Path & "\PO.rpt"
    .DiscardSavedData = True
    .SelectionFormula = "totext ({TRPOH.PONo}) >='" & Text1.Text & "' AND ({TRPOH.PONo}) <= '" & Text2.Text & "'"
    .RetrieveDataFiles
    .SortFields(0) = "+{TRPOD.SortNumber}"
    .Action = 1
    End With
    End Sub
    Sub PrintPO3()
    With CRT
    .Connect = "dsn=192.168.0.2;uid=sa;pwd=sa123sa;dsq=iats"
    .ReportFileName = App.Path & "\PO.rpt"
    .DiscardSavedData = True
    .SelectionFormula = "totext ({TRPOH.PONo}) >='" & Text1.Text & "' AND ({TRPOH.PONo}) <= '" & Text2.Text & "'"
    .SelectionFormula = "totext ({TRPOH.SuppCode}) ='" & Text3.Text & "'"
    .RetrieveDataFiles
    .SortFields(0) = "+{TRPOD.SortNumber}"
    .Action = 1
    End With
    How to set the CRT.Connect as General, so if i change the connection, i'm not change for 3 times of code, so i only change one.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,102

    Re: Simple way for Crystal Report Code in Vb6

    You can store your connectionstring "dsn=192.168.0.2;uid=sa;pwd=sa123sa;dsq=iats" to a variable then use that variable in your connect.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    New Member stevlo's Avatar
    Join Date
    Oct 2021
    Location
    Somewhere
    Posts
    2

    Re: Simple way for Crystal Report Code in Vb6

    Quote Originally Posted by dee-u View Post
    You can store your connectionstring "dsn=192.168.0.2;uid=sa;pwd=sa123sa;dsq=iats" to a variable then use that variable in your connect.
    +1 for this.

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