Results 1 to 4 of 4

Thread: Help With Code

  1. #1
    Join Date
    Nov 2002
    Posts
    2

    Unanswered: Help With Code

    I have a mainform (Audit Summary) and a subform (frmdeficienciessub). Within the mainform a control named Def with two values either Y or N. If Y is entered then there is a need to go to the subform, if N is entered then the requirement is not needed and user can proceed to the next record. I think I need code in the afterupdate event but do not know how to go about it. Can someone help me with this ?
    If Def.Value = "Y" Then
    Forms!Audit_Summary!frmDeficienciessub.SetFocus
    Forms!frmDeficienciessub!Mill#.SetFocus
    ElseIf Def.Value = "N" Then
    'top of page
    DoCmd.GoToPage 1,0,0
    'next record
    DoCmd.GotoRecord acDataForm, "frmAudit_Summary", acGoTo, 7
    End If
    End Sub

    I get Runtime Error 2489 "The object frmAudit_Summary isn't open" debugger goes to this line DoCmd.GoToRecord acDataForm, "frmAudit_Summary", acGoTo, 7
    I have changed to Audit summary etc. and get the same error. frmAudit_Summary is my main form
    Thanks

  2. #2
    Join Date
    Sep 2002
    Location
    Land of OZ
    Posts
    173

    Re: Help With Code

    What version of Access are you using.

    I mocked up a quick two table structure with some code that does function. This is done in access 97

    Hope this helps.

    Originally posted by jmcwk
    I have a mainform (Audit Summary) and a subform (frmdeficienciessub). Within the mainform a control named Def with two values either Y or N. If Y is entered then there is a need to go to the subform, if N is entered then the requirement is not needed and user can proceed to the next record. I think I need code in the afterupdate event but do not know how to go about it. Can someone help me with this ?
    If Def.Value = "Y" Then
    Forms!Audit_Summary!frmDeficienciessub.SetFocus
    Forms!frmDeficienciessub!Mill#.SetFocus
    ElseIf Def.Value = "N" Then
    'top of page
    DoCmd.GoToPage 1,0,0
    'next record
    DoCmd.GotoRecord acDataForm, "frmAudit_Summary", acGoTo, 7
    End If
    End Sub

    I get Runtime Error 2489 "The object frmAudit_Summary isn't open" debugger goes to this line DoCmd.GoToRecord acDataForm, "frmAudit_Summary", acGoTo, 7
    I have changed to Audit summary etc. and get the same error. frmAudit_Summary is my main form
    Thanks
    Attached Files Attached Files

  3. #3
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    try simplifing

    DoCmd.GoToRecord , , acNext

    is all i doa nd as long as the focus is right this works
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  4. #4
    Join Date
    Nov 2002
    Posts
    2

    Talking

    Thank You All for the input your suggestions were right on, it workks wonderfully

Posting Permissions

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