Hi all, hope someone can be of help. have successfully created routine to open an existing report, set it's record source to an SQL statement and print it out. This is done in VBA through an Access form. What i would like to do is open the report from a VB6 front end, set the record source to an SQL statement, print it out, save the report under a new name leaving the original template untouched. of course all this will occur without Access being visible to the user!This would be useful for archival purposes on a system I'm putting together. My code for the original approach is below:
VB Code:
Private Sub cmdReport_Click() Dim strSQL As String strSQL = "Select tblTransaction.UserID, tblTransaction.TransactionNumber,tblDetails.Quantity, tblProduct.SellPrice, tblProduct.Description, (tblDetails.Quantity * tblProduct.SellPrice) As Total From tblTransaction, tblDetails, tblProduct" & _ " Where Month(Now) = Month (tblTransaction.SellDate)And tblTransaction.TransactionNumber = tblDetails.TransactionNumber And tblDetails.ProductID=tblProduct.ProductID Group By tblTransaction.UserID, tblTransaction.TransactionNumber, tblProduct.Description, tblDetails.Quantity, tblProduct.SellPrice;" DoCmd.Echo False DoCmd.OpenReport "rptTemplate", acViewDesign Reports("rptTemplate").RecordSource = strSQL DoCmd.Close , , acSaveYes DoCmd.Echo True DoCmd.OpenReport "rptTemplate", acViewNormal DoCmd.Close , "rptTemplate", acSaveYes End Sub
Could some one point me in the right direction as to how to do this please?
Thanks, Lol![]()




Reply With Quote