Results 1 to 5 of 5
  1. #1
    Madmax is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    80

    sub form correct answer adds to the number correct in main form HELP!

    The code I have is.


    Code:
    Private Sub Command26_Click()
    If Forms![test site]![prp test].Form.[A Right Answer] = -1 Then
    Forms![test site]![number correct] = Forms![test site]![number correct] + 1
    End If
    DoCmd.FindNext
    End Sub
    I know this is wrong but what this does starts with a button that says answer A. Then when clicked it checks a yes/no box to see if "A right Answer" is the correct yes. Then it should pop to the main form and take the number correct cell and add one to it. everytime I clikc this, nothing is happening.

    Also, in this code. I am trying to get the record to go to the next record inside the subform but docmd.findnext seems to be wrong too.

    Please help me out.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,915
    FindNext method is not appropriate, need something like:

    DoCmd.GoToRecord acForm, Me.Name, acNext

    Have you step debugged? Follow the code as it executes, see where behavior deviates from expectations, fix, repeat.

    Try = True instead of -1.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Madmax is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    80
    Private Sub Command26_Click()
    If Forms![test site]![prp test].Form.[A Right Answer] = True Then
    Forms![test site]![number correct] = Forms![test site]![number correct] + 1
    Debug.Print
    Else
    DoCmd.GoToRecord acDataForm, Me.Question, acNext
    End If
    End Sub
    Nothing shows on debug I did this

    Forms![test site]![number correct] = 1
    and that showed 1 in the correct cell but I cant get it to add 1 to whatever number is there.

  4. #4
    Madmax is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    80
    disregard last. though nothing showed on debug, it still started working correctly, new problem is the go to record wont work for the subform. attached is code again.


    Private Sub Command26_Click()
    If Forms![test site]![prp test].Form.[A Right Answer] = True Then
    If Forms![test site]![number correct] = 0 Then
    Forms![test site]![number correct] = 1
    DoCmd.GoToRecord acDataForm, Me.CurrentRecord, acNext
    Exit Sub
    End If
    Forms![test site]![number correct] = Forms![test site]![number correct] + 1
    DoCmd.GoToRecord acDataForm, Me.CurrentRecord, acNext
    Else
    DoCmd.GoToRecord acDataForm, Me.CurrentRecord, acNext
    End If
    End Sub
    I dont want it to change the record on the primary form just the subform named"PRP test" the main form is named "Test site"

  5. #5
    Madmax is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    80
    lol I was making it too complicated, the answer was

    DoCmd.gotorecord , , acnext.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 06-26-2011, 09:14 PM
  2. Form Not Opening Correct Record
    By halfaguava in forum Forms
    Replies: 1
    Last Post: 06-09-2011, 07:00 PM
  3. Can System Restore correct Form Size issue
    By fordtough in forum Forms
    Replies: 0
    Last Post: 04-12-2011, 02:56 PM
  4. Opening form to correct record. Bookmark?
    By stephenaa5 in forum Forms
    Replies: 11
    Last Post: 12-29-2009, 02:43 PM
  5. Replies: 0
    Last Post: 06-23-2009, 03:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums