Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Posts
    2

    Question Unanswered: Use Temp file in Report

    Hello all,

    I've use VBA to create a temp file from the query of my access97 database. How can I use this in my report form ?

    I use the following statement to create the temp result file.

    Dim Qry as query
    Dim tQry as querydef
    Dim rs as recordset

    set Qry = currentdb.querydefs("Query1")
    set tQry= CurrentDb.CreateQueryDef("", Qry.SQL)

    Set rs = tQry.OpenRecordset()

    I use this method since I like to do some calculation in the temp result file and do not like to leave it in the MDB file after printing the report.

    Best regards,

  2. #2
    Join Date
    Dec 2002
    Posts
    18

    maybe too simple...

    why not set the Qry.SQL as the recordsource of the report/form?
    I think it is in the load event, but it could be the open event

    Dim Qry as query
    set Qry = currentdb.querydefs("Query1")

    Me.Recordsource=Qry.SQL

  3. #3
    Join Date
    Dec 2002
    Posts
    2

    Smile

    Thank you for the reply.

    As my last message wrote that I need to do some updating operation in the output result temp file.

    Besides I also need to assign the inputted value from another form to the Query - "Query1"

    Dim p1 as parameter, p2 as parameter

    set tQry= CurrentDb.CreateQueryDef("", Qry.SQL)
    set p1=tQry.Parameter(1)
    set p2=tQry.Parameter(2)

    p1= [FromDate]
    p2= [ToDate]

    Set rs = tQry.OpenRecordset()

  4. #4
    Join Date
    Dec 2002
    Posts
    18
    I take it you have tried

    Me.Recordsource=tQry.SQL
    instead of opening the recordset

Posting Permissions

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