Selasa, 21 Juni 2016

RE: [MS_AccessPros] Having issue with gotorecord in access 2010/2013


The Find_SkipRecord determines which questions have been skipped (works).  I miss spoke about adding the line

  DoCmd.GoToRecord , Record:=acFirst
it causes the same issue.

I did notice that the error appears to only happen when I am debugging code and not when the app is run normally.  That does not make sense to me.

---In, <liz_ravenwood@...> wrote :

What does the procedure Find_SkipRecord do?


From: []
Sent: Tuesday, June 21, 2016 9:12 AM
Subject: [MS_AccessPros] Having issue with gotorecord in access 2010/2013


I am developing a test/survey app.  The questions are a randomized subset of questions.  Each question in the test needs to be answered.  I track the number of questions in the test are left blank then will represent the questions at the end so the user can try again.   The issue is when I try to go back to the question I get the following error:


Error 2046: The command or action 'GoToRecord' isn't available now.


the following is the code be used  the issue occurs in the following seqment:

         If lngSkip > 0 Then
            boolRedisplay = True
            MsgBox " lngTe! stRcd = " & lngTestRcd
            Dim tmpr As Long
            tmpr = 3
            DoCmd.GoToRecord , "frmTest", Record:=tmpr


Not sure what is causing the error.  The tmpr variable is being used as a test for the code.  I added a line

         DoCmd.GoToRecord , Record:=acFirst

just after the "if" statement with no issues.

Any suggestions would be appreciated.



==============complete routine===========================================

Private Sub Cmd_Submit_Click()
Dim dbs As Database
Dim ctl As Control
Dim tmpName As String
Dim tmpAns As Long
Dim boolAns As Boolean

On Error GoTo Err! orHandler

   Set dbs = CurrentDb(! )
   ' Determine which option is selected
   For Each ctl In Me.Controls
     If ctl.ControlType = acCheckBox Then
       tmpName = ctl.Name
       If (Me.Controls(tmpName)) Then
          tmpAns = CLng(Mid(tmpName, 7))
       End If
     End If
   Next ctl
   'Compare answer to correct answer
   If (tmpAns = lngCorrectAns) Then
      MsgBox "Correct"
      boolAns = True
      Me.Controls("Option" & Trim(Str(lngCorrectAns))).SetFocus
      MsgBox "That is incorrect. The answer is: " & vbCrLf _
  &n! bsp;         & Me.Controls("Option" & Trim(Str(lngCorrectAns))).Text
      boolAns = False
   End If
   If Not boolRedisplay Then
      ' Write data to complete registration
      dbs.Execute "INSERT INTO tblTestHistory (lngEmployeeID, lngQClassID, ID_Question, lngCorrectAns, lngUserAns, boolCorrect, strTestDate, lngSession) " _
           & "VALUES (" & ID.Value & ", " & Class.Value & ", " & Question.Value & ", " & lngCorrectAns & ", " & tmpAns & ", " & boolAns & ", '" & Date & "', " & Session.Value & ");"
  &n! bsp;
      If CurrentRecord < Recordset! Clone.RecordCount Then
         ' Next Record
         DoCmd.GoToRecord , "frmTest", Record:=acNext, Offset:=1
         If lngSkip > 0 Then
            boolRedisplay = True
            MsgBox " lngTestRcd = " & lngTestRcd
            Dim tmpr As Long
            tmpr = 3
            DoCmd.GoToRecord , "frmTest", Record:=tmpr
  &nbs! p;         DoCmd.Close acForm, "frmTest", acSaveNo
            DoCmd.OpenForm "frmUserTestResults", acNormal
         End If
      End If
      ' Update existing record lngTestRcd
      dbs.Execute "Update tblTestHistory (SET  ([lngUserAns] = " & tmpAns & ", [boolCorrect] = " & boolAns & ") " _
           & "WHERE ([ID_History] = " & lngTestRcd & ");"
      lngSkip = lngSkip - 1
      If lngSkip > 0 Then
 &nb! sp;       DoCmd.GoToRecord , Record:=acFi! rst
      End If
   End If

    On Error GoTo 0
    Exit Sub
    Call LogError(Err.Number, Err.Description, "frmTest-Cmd_Submit")
    Resume ExitPoint
End Sub



This email (and all attachments) is for the sole use of the intended recipient(s) and may contain privileged and/or proprietary information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.


Posted by:
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.



Tidak ada komentar:

Posting Komentar