Selasa, 21 Juni 2016

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

 

What does the procedure Find_SkipRecord do?

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Tuesday, June 21, 2016 9:12 AM
To: MS_Access_Professionals@yahoogroups.com
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
            Find_SkipRecord
            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.

Rof

 

==============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
   Else
      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
      Else
         If lngSkip > 0 Then
            Find_SkipRecord
            boolRedisplay = True
            MsgBox " lngTestRcd = " & lngTestRcd
            Dim tmpr As Long
            tmpr = 3
            DoCmd.GoToRecord , "frmTest", Record:=tmpr
         Else
  &nbs! p;         DoCmd.Close acForm, "frmTest", acSaveNo
            DoCmd.OpenForm "frmUserTestResults", acNormal
         End If
      End If
   Else
      ' Update existing record lngTestRcd
     
      dbs.Execute "Update tblTestHistory (SET  ([lngUserAns] = " & tmpAns & ", [boolCorrect] = " & boolAns & ") " _
           & "WHERE ([ID_History] = " & lngTestRcd & ");"
      lngSkip = lngSkip - 1
      If lngSkip > 0 Then
         Find_SkipRecord
 &nb! sp;       DoCmd.GoToRecord , Record:=acFi! rst
      Else
      End If
   End If

ExitPoint:
    On Error GoTo 0
    dbs.Close
    Exit Sub
   
ErrorHandler:
    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: Liz Ravenwood <Liz_Ravenwood@beaerospace.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

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