Results 1 to 30 of 30

Thread: Access report with a twist

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    26

    Resolved Access report with a twist

    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:
    1. Private Sub cmdReport_Click()
    2. Dim strSQL As String
    3. strSQL = "Select tblTransaction.UserID, tblTransaction.TransactionNumber,tblDetails.Quantity, tblProduct.SellPrice, tblProduct.Description, (tblDetails.Quantity * tblProduct.SellPrice) As Total  From tblTransaction, tblDetails, tblProduct" & _
    4. " 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;"
    5. DoCmd.Echo False
    6. DoCmd.OpenReport "rptTemplate", acViewDesign
    7. Reports("rptTemplate").RecordSource = strSQL
    8. DoCmd.Close , , acSaveYes
    9. DoCmd.Echo True
    10. DoCmd.OpenReport "rptTemplate", acViewNormal
    11. DoCmd.Close , "rptTemplate", acSaveYes
    12. End Sub

    Could some one point me in the right direction as to how to do this please?

    Thanks, Lol
    Last edited by Lol Owen; Apr 12th, 2005 at 04:48 PM.

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