Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    8

    Unhappy Unanswered: Closing Dynamically Generated Forms and Reports Without Saving

    I have another interesting one for anyone out there who can solve it.

    I have an application that creates certain forms and reports completely in VBA. I need to know how I can set up the forms and reports so that they don't ask if the user wants to save them when they close the form or report because the form or report is generated fresh each time it is used. If the user saves it, there will eventually be dozens of copies in the database.

    For the form I have disabled the control box and close button and added a command button on the form that calls:

    docmd.close acForm, FormName, acSaveNo

    This works, but is not the preferred method. I want the close box on the form for consistency with the rest of the app.

    There is also no way to do this with a report.

    Any ideas?

  2. #2
    Join Date
    Jan 2004
    Posts
    8
    Here is the function that creates the report


    Function CreateSurveyReport(QuestionSet As String)
    On Error GoTo CreateSurveyReport_Err

    Dim ctlText As Control
    Dim rpt As Report
    Dim rs, RSAnswers As DAO.Recordset
    Dim Xc, Yc, I As Integer
    Dim Sql, SQLAnswers As String

    Sql = "SELECT tlkpQuestionSets.QuestionSet, tlkpQuestionSets.Question, tlkpQuestionList.Question FROM tlkpQuestionSets LEFT JOIN tlkpQuestionList ON tlkpQuestionSets.Question = tlkpQuestionList.QuestionNumber WHERE (((tlkpQuestionSets.QuestionSet)='" & QuestionSet & "'));"

    Set rpt = CreateReport
    Set rs = CurrentDb.OpenRecordset(Sql)

    rpt.Caption = "Survey Data"
    rpt.Section(acPageHeader).Height = 0
    rpt.Section(acPageFooter).Height = 0
    Yc = 100
    I = 0

    If Not rs.EOF Then

    Set ctlText = CreateReportControl(rpt.Name, acLabel, , "", "", 0, Yc, 9000, 500)
    ctlText.Caption = "Hello and Welcome to Environment Canada's LET'S DRIVE GREEN Program"
    ctlText.FontWeight = 700
    ctlText.FontSize = 12
    Yc = Yc + 750

    Set ctlText = CreateReportControl(rpt.Name, acLabel, , "", "", 100, Yc, 7000, 750)
    ctlText.Caption = "Thank you for taking the time to come to this emissions clinic and for helping us by filling out this survey."
    ctlText.FontWeight = 700
    ctlText.FontSize = 10
    Yc = Yc + 750

    Set ctlText = CreateReportControl(rpt.Name, acLabel, , "", "", 100, Yc, 7000, 750)
    ctlText.Caption = "If you have any questions please do not hesitate to ask the volunteer staff or an Environment Canada employee."
    ctlText.FontWeight = 700
    ctlText.FontSize = 10
    Yc = Yc + 750

    Set ctlText = CreateReportControl(rpt.Name, acLine, , "", "", 0, Yc, 9300, 0)
    ctlText.BorderWidth = 2
    Yc = Yc + 250

    rs.MoveLast
    rs.MoveFirst
    While Not rs.EOF
    I = I + 1
    Set ctlText = CreateReportControl(rpt.Name, acLabel, , "", "", 100, Yc, 9000, 450)
    ctlText.Caption = I & ". " & rs.Fields(2).Value
    ctlText.Name = rs.Fields(1).Value
    ctlText.FontWeight = 700
    ctlText.SizeToFit
    Yc = Yc + ctlText.Height + 50

    SQLAnswers = "SELECT tlkpQuestionAnswers.Answer FROM tlkpQuestionAnswers WHERE (((tlkpQuestionAnswers.QuestionNumber)='" & rs.Fields(1).Value & "') AND ((tlkpQuestionAnswers.Answer)<>'No response'));"
    Set RSAnswers = CurrentDb.OpenRecordset(SQLAnswers)

    If Not RSAnswers.EOF Then
    RSAnswers.MoveLast
    RSAnswers.MoveFirst

    Xc = 500

    While Not RSAnswers.EOF
    Set ctlText = CreateReportControl(rpt.Name, acCheckBox, , "", "", Xc - 250, Yc + 30, 250, 250)
    Set ctlText = CreateReportControl(rpt.Name, acLabel, , "", "", Xc, Yc, 2900, 250)
    ctlText.Caption = RSAnswers.Fields(0).Value
    RSAnswers.MoveNext
    If Xc + 2900 < 9000 Then
    Xc = Xc + 2900
    Else
    Xc = 500
    Yc = Yc + 300
    End If
    Wend

    If Xc <> 500 Then Yc = Yc + 300

    End If

    Yc = Yc + 100
    rs.MoveNext

    Wend

    DoCmd.OpenReport rpt.Name, acViewPreview

    End If

    CreateSurveyReport_Exit:
    Exit Function

    CreateSurveyReport_Err:
    MsgBox Err.Description
    Resume CreateSurveyReport_Exit

    End Function

  3. #3
    Join Date
    Feb 2004
    Location
    Shirak
    Posts
    6
    Cześć SParki wylizałeś ostatnio jakieś szparki?

  4. #4
    Join Date
    Jan 2004
    Posts
    8

    Re: Closing Dynamically Generated Forms and Reports Without Saving

    Anyone?

Posting Permissions

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