runtime error 2001 only when open tabbed form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmoudy77
    New Member
    • Sep 2007
    • 20

    #1

    runtime error 2001 only when open tabbed form

    I've got some vb code that gives me a "previous operation cancelled" error when I try and open the form as a subform in a tabbed control. When I open the form itself I don't get the error. Does DSum() not agree with the tabbed control?

    I'm posting the code below.

    Private Sub Form_Load()

    ERROR STARTS HERE and continues to the next line if I remove the previous function.
    DSumDay = DSum("[Day]", "StandsQ")

    DSumNight = DSum("[Night]", "StandsQ")

    DSumNVG = DSum("[NVG]", "StandsQ")

    DSumHood = DSum("[Hood]", "StandsQ")

    Text89 = DMax("[Date]", "StandsQ", "[STANDS Eval] = True")
    Text90 = DMax("[Date]", "StandsQ", "[INST Eval] = True")
    Text91 = DMax("[Date]", "StandsQ", "[NVG Eval] = True")
    Text92 = DMax("[Date]", "StandsQ", "[NO NOTICE] = True")
    Text93 = DMax("[Date]", "StandsQ", "[Table III/IV] = True")
    Text94 = DMax("[Date]", "StandsQ", "[Table VII/VIII] = True")
    Text95 = DMax("[Date]", "StandsQ", "[Table IX/X] = True")
    SAEH = DMax("[Date]", "StandsQ", "[SAEH] = True")
    FADEC = DMax("[Date]", "StandsQ", "[FADEC] = True")
    CBAT = DMax("[Date]", "StandsQ", "[CBAT] = True")
    CBRN = DMax("[Date]", "StandsQ", "[CBRN] = True")
    [Last NVG] = DMax("[Date]", "StandsQ", "[NVG] > 0")
    [Last Flt] = DMax("[Date]", "StandsQ")
    Total = DSumDay + DSumNight + DSumNVG + DSumHood
    [NVG Time] = DSumNVG
    [PC Time] = DSum("[Day] + [Night] + [NVG] + [Hood]", "StandsQ", "[PC] = True")
    End Sub
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    Originally posted by jmoudy77
    I've got some vb code that gives me a "previous operation cancelled" error when I try and open the form as a subform in a tabbed control. When I open the form itself I don't get the error. Does DSum() not agree with the tabbed control?

    I'm posting the code below.

    Private Sub Form_Load()

    ERROR STARTS HERE and continues to the next line if I remove the previous function.
    DSumDay = DSum("[Day]", "StandsQ")

    DSumNight = DSum("[Night]", "StandsQ")

    DSumNVG = DSum("[NVG]", "StandsQ")

    DSumHood = DSum("[Hood]", "StandsQ")

    Text89 = DMax("[Date]", "StandsQ", "[STANDS Eval] = True")
    Text90 = DMax("[Date]", "StandsQ", "[INST Eval] = True")
    Text91 = DMax("[Date]", "StandsQ", "[NVG Eval] = True")
    Text92 = DMax("[Date]", "StandsQ", "[NO NOTICE] = True")
    Text93 = DMax("[Date]", "StandsQ", "[Table III/IV] = True")
    Text94 = DMax("[Date]", "StandsQ", "[Table VII/VIII] = True")
    Text95 = DMax("[Date]", "StandsQ", "[Table IX/X] = True")
    SAEH = DMax("[Date]", "StandsQ", "[SAEH] = True")
    FADEC = DMax("[Date]", "StandsQ", "[FADEC] = True")
    CBAT = DMax("[Date]", "StandsQ", "[CBAT] = True")
    CBRN = DMax("[Date]", "StandsQ", "[CBRN] = True")
    [Last NVG] = DMax("[Date]", "StandsQ", "[NVG] > 0")
    [Last Flt] = DMax("[Date]", "StandsQ")
    Total = DSumDay + DSumNight + DSumNVG + DSumHood
    [NVG Time] = DSumNVG
    [PC Time] = DSum("[Day] + [Night] + [NVG] + [Hood]", "StandsQ", "[PC] = True")
    End Sub
    Day and Date are reserved words in ms access, and should not be used as field names. Try changing the names to something like MyDay and MyDate and see if that helps

    Also, what is this? This is not proper syntax for the DSum function
    Total = DSumDay + DSumNight + DSumNVG + DSumHood
    [NVG Time] = DSumNVG
    [PC Time] = DSum("[Day] + [Night] + [NVG] + [Hood]", "StandsQ", "[PC] = True")

    Comment

    • jmoudy77
      New Member
      • Sep 2007
      • 20

      #3
      I cleaned up the Syntax a bit to try and fix the Day and Date issues and to eliminate comfusion.

      I'm still getting the error when I try and open the form that has this form nested as a subform in a tab control.

      I'm still not getting an error and everything works fine when I open the form directly. Here's the new code.


      Private Sub Form_Load()

      Dim DaySum As Integer
      DaySum = DSum("[DayTime]", "StandsQ")
      Dim NightSum As Integer
      NightSum = DSum("[Night]", "StandsQ")
      Dim NVGSum As Integer
      NVGSum = DSum("[NVG]", "StandsQ")
      Dim HoodSum As Integer
      HoodSum = DSum("[Hood]", "StandsQ")

      Stands = DMax("[FltDate]", "StandsQ", "[STANDS Eval] = True")
      Inst = DMax("[FltDate]", "StandsQ", "[INST Eval] = True")
      NVGEval = DMax("[FltDate]", "StandsQ", "[NVG Eval] = True")
      NoNotice = DMax("[FltDate]", "StandsQ", "[NO NOTICE] = True")
      TableIII = DMax("[FltDate]", "StandsQ", "[Table III/IV] = True")
      TableVII = DMax("[FltDate]", "StandsQ", "[Table VII/VIII] = True")
      TableIX = DMax("[FltDate]", "StandsQ", "[Table IX/X] = True")
      SAEH = DMax("[FltDate]", "StandsQ", "[SAEH] = True")
      FADEC = DMax("[FltDate]", "StandsQ", "[FADEC] = True")
      CBAT = DMax("[FltDate]", "StandsQ", "[CBAT] = True")
      CBRN = DMax("[FltDate]", "StandsQ", "[CBRN] = True")
      [Last NVG] = DMax("[FltDate]", "StandsQ", "[NVG] > 0")
      [Last Flt] = DMax("[FltDate]", "StandsQ")
      Total = DaySum + NightSum + NVGSum + HoodSum
      [NVG Time] = NVGSum
      [PC Time] = DSum("[DayTime] + [Night] + [NVG] + [Hood]", "StandsQ", "[PC] = True")

      End Sub

      Comment

      • puppydogbuddy
        Recognized Expert Top Contributor
        • May 2007
        • 1923

        #4
        Originally posted by jmoudy77
        I cleaned up the Syntax a bit to try and fix the Day and Date issues and to eliminate comfusion.

        I'm still getting the error when I try and open the form that has this form nested as a subform in a tab control.

        I'm still not getting an error and everything works fine when I open the form directly. Here's the new code.

        Code:
        Private Sub Form_Load()
        
        Dim DaySum As Integer
        DaySum = DSum("[DayTime]", "StandsQ")
        Dim NightSum As Integer
        NightSum = DSum("[Night]", "StandsQ")
        Dim NVGSum As Integer
        NVGSum = DSum("[NVG]", "StandsQ")
        Dim HoodSum As Integer
        HoodSum = DSum("[Hood]", "StandsQ")
        
            Stands = DMax("[FltDate]", "StandsQ", "[STANDS Eval] = True")
            Inst = DMax("[FltDate]", "StandsQ", "[INST Eval] = True")
            NVGEval = DMax("[FltDate]", "StandsQ", "[NVG Eval] = True")
            NoNotice = DMax("[FltDate]", "StandsQ", "[NO NOTICE] = True")
            TableIII = DMax("[FltDate]", "StandsQ", "[Table III/IV] = True")
            TableVII = DMax("[FltDate]", "StandsQ", "[Table VII/VIII] = True")
            TableIX = DMax("[FltDate]", "StandsQ", "[Table IX/X] = True")
            SAEH = DMax("[FltDate]", "StandsQ", "[SAEH] = True")
            FADEC = DMax("[FltDate]", "StandsQ", "[FADEC] = True")
            CBAT = DMax("[FltDate]", "StandsQ", "[CBAT] = True")
            CBRN = DMax("[FltDate]", "StandsQ", "[CBRN] = True")
            [Last NVG] = DMax("[FltDate]", "StandsQ", "[NVG] > 0")
            [Last Flt] = DMax("[FltDate]", "StandsQ")
            Total = DaySum + NightSum + NVGSum + HoodSum
            [NVG Time] = NVGSum
            [PC Time] = DSum("[DayTime] + [Night] + [NVG] + [Hood]", "StandsQ", "[PC] = True")
            
        End Sub
        Your code looks much better.

        Does your error occur whenever you click the tab control or does it occur just in the form load event without clicking the tab control? Have you set the master/child links between your main form and your subform?

        Comment

        • jmoudy77
          New Member
          • Sep 2007
          • 20

          #5
          The error occurs when the main form loads. I don't think it has anything to do with the tabbed control, because I created a new form to troubleshoot and added a subform with this form as its object source(no tabbed control).

          I got the same error when I tried to open the new main form

          Should there be any reason to use master/child linking between the main and subforms if I nothing but the subform on the main form?

          Comment

          • puppydogbuddy
            Recognized Expert Top Contributor
            • May 2007
            • 1923

            #6
            Originally posted by jmoudy77
            The error occurs when the main form loads. I don't think it has anything to do with the tabbed control, because I created a new form to troubleshoot and added a subform with this form as its object source(no tabbed control).

            I got the same error when I tried to open the new main form

            Should there be any reason to use master/child linking between the main and subforms if I nothing but the subform on the main form?
            jmoudy,

            Yes, there is. The master/child links (or code equivalent) are needed in order for the form/subform to work together in an organized fashion, If you have no controls on the main form, you can use the hidden textbox trick.

            1. Place an unbound textbox named (for example) txtMasterLink on your main form. Set its control source to:= Forms!YourMain! YourSubformCont rol.Form!YourCh ildLinkField.(t he field that drives your subform)

            2. Go to subform control on the border between the main form and the subform, invoke the property sheet, and put the following for master and child links.

            Master Link: txtMasterLink
            Child Link: the bound linkfield on your subform that corresponds to the master link
            3. Test and see if it works. If it works ok, then you can set the visible property of txtMasterLink to False to hide it.

            Comment

            • jmoudy77
              New Member
              • Sep 2007
              • 20

              #7
              I recoded the form to pull info from the table rather than a query, that seemed to fix that problem.

              The only issue I'm having with it now is that it won't allow me to navigate between records. It pulls the first record and then shows an empty record when next or prev record is selected.

              BTW, I really appreciate the help.


              Private Sub Form_Load()



              [Stands] = DMax("[FltDate]", "Flight Data", "[STANDS Eval] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [Inst] = DMax("[FltDate]", "Flight Data", "[INST Eval] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [NVGEval] = DMax("[FltDate]", "Flight Data", "[NVG Eval] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [NoNotice] = DMax("[FltDate]", "Flight Data", "[NO NOTICE] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [TableIII] = DMax("[FltDate]", "Flight Data", "[Table III/IV] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [TableVII] = DMax("[FltDate]", "Flight Data", "[Table VII/VIII] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [TableIX] = DMax("[FltDate]", "Flight Data", "[Table IX/X] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [SAEH] = DMax("[FltDate]", "Flight Data", "[SAEH] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [FADEC] = DMax("[FltDate]", "Flight Data", "[FADEC] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [CBRN] = DMax("[FltDate]", "Flight Data", "[CBRN] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [Last NVG] = DMax("[FltDate]", "Flight Data", "[NVG] > 0 And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [Last Flt] = DMax("[FltDate]", "Flight Data", "[FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [Total] = DSum("[DayTime] + [Night] + [NVG] + [Hood]", "Flight Data", "[FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [NVG Time] = DSum("[DayTime] + [Night] + [NVG] + [Hood]", "Flight Data", "[NVG] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")
              [PC Time] = DSum("[DayTime] + [Night] + [NVG] + [Hood]", "Flight Data", "[PC] = True And [FltName] = '" & Forms![AV2]![AVSTATS2].Form![Name1] & "'")

              End Sub

              Comment

              • puppydogbuddy
                Recognized Expert Top Contributor
                • May 2007
                • 1923

                #8
                Originally posted by jmoudy77
                I recoded the form to pull info from the table rather than a query, that seemed to fix that problem.

                The only issue I'm having with it now is that it won't allow me to navigate between records. It pulls the first record and then shows an empty record when next or prev record is selected.

                BTW, I really appreciate the help.
                Check your form properties. Should be as follows:
                allow additons = yes
                allow edits = yes
                data entry = no

                Comment

                Working...