Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Charlotte, NC

    Question Unanswered: Why Doesn't This work Right?

    This is all the code for my REPORT named Generated_Test:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    'Parsing Info
    Dim AnswerLetter As String
    Dim PaperID As String
    Dim QuestionNumber As Integer

    Dim DBName As String
    DBName = "CorrectAnswers"

    'Generates Parsing Values
    AnswerLetter = "A or B or C"
    PaperID = "Version A"
    QuestionNumber = Me.Text27

    'Appends answers to CorrectAnswer database

    DoCmd.SetWarnings False
    appendSql = "INSERT INTO CorrectAnswers(PaperID,QuestionNumber, " & _
    "AnswerLetter) SELECT '" & PaperID & "'," & QuestionNumber & " ,'" & _
    AnswerLetter & "'"
    DoCmd.RunSQL appendSql
    DoCmd.SetWarnings True

    End Sub

    When you open the report.. it displays questions from my database (Test #1). It then should create an Answer Sheet in the database (CorrectAnswer).

    My problem: If I have a 7 question (Test #1) database.. after I run the report (which displays fine).. the CorrectAnswer database has answers 1-7 (which are all wrong) and another 1-7 (which are all right) appended to it. For a total of 14 answers.

    Can anyone see why this code would cycle the database twice? Appending data to my database two times...

    "How much deeper would the ocean be without sponges?"

  2. #2
    Join Date
    Dec 2002
    Sounds like the Detail section is formating twice.

    One way to see if it is formatting twice is to put a 'msgbox' in the event code and open the report. Count how many times the msgbox appears.

    If it is formatting more than once, check out the Retreat Event in help.

    Hope this helps.


  3. #3
    Join Date
    Oct 2002
    Charlotte, NC

    Post Update

    Thanks for the advice.

    I did take off "warnings" and found when it was appending when it shouldn't. It was appending during the creation of the Report Header.

    I couldn't figure out what was causing it.. but I attached an SQL statement to immediatly delete what it attaches wrong.


    "How much deeper would the ocean be without sponges?"

Posting Permissions

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