Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116

    Unhappy Unanswered: Operation Cancelled error

    Can anyone tell me why I would get an error saying "you cancelled the previous operation?"

    Sub EnterAnswer(TAns As String)
    Dim NumOfRecords As Integer


    NumOfRecords = DCount("TEmployeeID", "tblQuizTemp", "TEmployeeID = " & [qzEmployeeID] & " AND TCourseID = " & [CourseID] & " AND TQuestionID = " & [QuestionID])

    If NumOfRecords > 0 Then
    If MsgBox("You have already answered this question. Do you want to change your answer?" _
    , vbYesNo + vbQuestion, "Your Title") = vbYes Then
    'OVERWRITE ANSWER IF RESPONCE IS 'YES'
    DoCmd.RunSQL "UPDATE tblQuizTemp " & _
    "SET TAnswer = " & TAns & _
    "WHERE TEmployeeID = " & [qzEmployeeID] & " AND TCourseID = " & [CourseID] & " AND TQuestionID = " & [QuestionID] & ";"
    End If
    Else 'NO RECORD EXISTS
    DoCmd.RunSQL "INSERT INTO tblQuizTemp (TEmployeeID, TCourseID, TQuestionID, TAnswer ) " & _
    "SELECT " & [qzEmployeeID] & " AS Expr1, " & [CourseID] & " AS Expr2, " & [QuestionID] & " AS Exp3, " & TAns & " AS Exp4 ;"

    End If
    End Sub

    Private Sub A_Click()
    EnterAnswer "1"
    End Sub

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    i don't use & _ so i have no idea if it automatically handles spaces.

    anyhow, assuming it doesn't, try adding a couple of spaces:

    "<here>WHERE TEmployeeID = " & [qzEmplo
    "<here>SELECT " & [qzEmployeeID] & " AS Ex

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Its an unhelpfull message from JET / VB. I think it occurs if there is some problem in the construction of the domain function. As I can't stand the domain function, horribly slow amongst other crimes can't help you much.

    Every time I hit one on Apps I have to support I rip 'em out for the perfomance gain. In one case a form that was a heavy user of dlookup I managed to improve the form load time from 10 minutes to 6 seconds with no toher changes. I was quite pleased so was the user base.

    It could be a malformed SQL statement. In fact if I were you I'd consider replacing the dcount with a select
    eg
    rs.open "select count(<field>) as Num of Records from ..... where ......;"

  4. #4
    Join Date
    Sep 2003
    Location
    Washington, DC
    Posts
    116
    The final answer thanks to Izy and MTB...

    http://www.dbforums.com/showpost.php...05&postcount=1

Posting Permissions

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