Run FastReport Using VBA

maxhugenmaxhugen Australia
edited 4:39AM in FastReport .NET
We're gradually migrating an MS Access application to .NET. Details are:
- Application delivered to users from server via Terminal Server (TS).
- MySQL database

We have purchased licenses for FastReport as reporting engine.

Until the app is fully migrated to .NET, we would like to run some FR reports from MS Access using VBA.

Can anyone advise me how to do this, or point me to some resources that describe a methodology pls?

MTIA!

Comments

  • edited 4:39AM
    from msaccess vba, use shellexecute (https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx) to run dotnet program.
    you could shellexecute to pass parameters.

    and dotnet program contains this code:
                Using cnn As New OleDBConnection(mySQLConnString)
                    cnn.Open()
    
                    Using cmd As New OleDBCommand()
                        cmd.Connection = cnn
                        cmd.CommandType = CommandType.Text
                        cmd.CommandText = "SELECT * FROM myTable WHERE ID = ?"
                        cmd.Parameters.AddWithValue("ID", id)
                        Using dr As OleDBDataReader = cmd.ExecuteReader()
                            Using dt As New DataTable()
                                dt.Load(dr)
                                dt.TableName = "MainReport"
    
                                report.Load(FullPathAppFolder + "Kupon.frx")
                                report.FileName = "Kupon"
                                report.RegisterData(dt, dt.TableName)
                                report.Prepare()
                                report.ShowPrepared()
                                report.Print()  'DIRECT TO PRINTER
                            End Using
                        End Using
                    End Using
                End Using
    

Leave a Comment