Mystery error message ... no Err# ... doesn't halt code ... where is it from

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • julietbrown
    New Member
    • Jan 2010
    • 99

    Mystery error message ... no Err# ... doesn't halt code ... where is it from

    On first reading you could stop at ** and resume at the later ** as I think the problem must be in the part before the first **!

    Field X on Form A is the key field for another table T. User enters, eg, "nnnn" in Field X.
    If Form A code discovers "nnnn" is not the key to an existing record in table T
    Form A opens Form B with acNewRecord and OpenArgs = "nnnn"
    When Form B opens, it places "nnnn" in a field Y (which is unbound, not the key field for the new record on Form B.) **
    User can, if wished, edit field Y, and then fill in rest of the new Table T record.
    When user clicks Save on Form B, Field Y is copied into the key field for the new Table T record and the record is saved.
    User can then hit "Back to Form A".
    If "nnnn" has been changed to, eg, "nnnnpq" while user is in Form B, the "Back to ... " button resets the field in Form A with the new value (i.e. replaces "nnnn" by "nnnnpq" in Field X on Form A.

    ** Sounds complicated, but it all works just FINE! Except .... (and I believe this has nothing to do with all that, beyond ** above) ... I get a mystery error message, AFTER Form B has been opened but BEFORE the user does anything at all.

    This mystery message just says "Property not found", and the only button on the message box is "OK"! There are no end/debug/help buttons, no Error #, and absolutely no indication of what property is "not found" or what it's a property of, or where I might find IT!!

    I've put a messagebox to myself in the OnOpen code for Form B, after it's done its stuff with the OpenArgs. I get that message BEFORE the mystery message, but I get the mystery message before I've done anything at all in Form B.

    Any ideas about the cause/source of this message?????
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Post your Open, Load, and current code here.

    Comment

    • julietbrown
      New Member
      • Jan 2010
      • 99

      #3
      There is no code in Load or Current. The code in Form_Open is below ...

      Code:
      Private Sub Form_Open(Cancel As Integer)
          If Not IsNull(OpenArgs) Then
              Me.OrgNameEntry = Trim(OpenArgs)
          Else
              MsgBox ("An error has occured: please click Cancel")
          End If
      End Sub
      The code in the other form that opens this one is ...

      Code:
          'check organisaion exists if not null, and if not, open the org form
          Dim rstOrg As Recordset
          Dim db As Database
          Set db = CurrentDb
          Set rstOrg = db.OpenRecordset("ORGANISATION", dbOpenDynaset)
          If (Not IsNull(Trim(Organisation))) Then
              If Not (rstOrg.EOF And rstOrg.BOF) Then
                  Organisation.SetFocus
                  rstOrg.FindFirst "OrganisationName = '" & Organisation.Text & "'"
                  If rstOrg.NoMatch Then
                      resp = MsgBox("The Organisation Name you have given does " _
                          & "not refer to an existing Organisation. " _
                          & "Check you have spelt it correctly.  " _
                          & "If 'Yes' the Manage Organisations form will open " _
                          & "so that you can enter such details as you currently have " _  
                          & "about the new organisation.", vbYesNo)
                      If resp = vbYes Then
                          Dim argStr As String
                          argStr = Organisation.Text
         DoCmd.OpenForm "ORGANISATION_FROM_CONTACT_Form", , , , , , argStr
                      End If
                      Cancel = True
                      Exit Sub
                  End If
              End If
          End If
      The form opens correctly, and performs correctly thereafter, apart from this little message box saying "Property not found" which occurs immediately AFTER the form has opened. If you just click "OK" on the message box, all is fine after that, but I can't fathom out what Property it's looking for!

      (I know I haven't closed the recordset ... sorry!)

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        I suspect the problem is with

        Me.OrgNameEntry = Trim(OpenArgs)


        I think the Form_Open event is too early to be assigning a value to a control. Try moving the code to the Form_Load event and see if resolves the problem.

        Linq ;0)>

        Comment

        • julietbrown
          New Member
          • Jan 2010
          • 99

          #5
          Oh dear! Your suggestion sounded SO completely sensible, I thought "Of course!" .... But sadly it made absolutely no difference - still got the 'Property not found' message. Also tried 'FormActivate' ... ditto!

          Comment

          • missinglinq
            Recognized Expert Specialist
            • Nov 2006
            • 3533

            #6
            What line is hilited when the code bombs?

            Also, in the calling form, where is the code you gave residing, ie what event is it in?

            Linq ;0)>

            Comment

            • julietbrown
              New Member
              • Jan 2010
              • 99

              #7
              That's precisely the problem ... It doesn't "bomb", it just carries on happily running, appearing to ignore its own error message! Because it doesn't "bomb" there's no line of code highlighted ... that would certainly help!!!

              The calling form is all the 'Contacts', the form that opens is to let user put in a new 'Organisation' with which the contact is associated.

              The call from the Contact form to the Organisation form is in the BeforeUpdate sub for the form. It's part of the validation of what the user has put in. If the Organisation they have entered is not already on file, the BeforeUpdate opens the Organisation form and then Cancels the update and Exits itself (which sounds rather uncomfortable!)

              Comment

              • nico5038
                Recognized Expert Specialist
                • Nov 2006
                • 3080

                #8
                I would place a break point on the line "Set db = CurrentDb" and use F8 to step line by line through the code till the message appears.
                I would also use "Me.Organisatio n" to refer to the formfield and change the tablename into tblOrganisation , thus making the difference between field and table clear.

                Nic;o)

                Comment

                • julietbrown
                  New Member
                  • Jan 2010
                  • 99

                  #9
                  Hello again! I haven't actually done what you said this time, because I was trying some sleuthing of my own, the results of which suggest what you said wouldn't have made any difference.

                  What I did was ...
                  1) Remove ALL the code from the called "ORGANISATION_F orm", and just open it using the existing code in the "CONTACT_Fo rm".
                  Result ... I still got the "Property not found" message.
                  2) Made a new blank form called "TEST_Form" , and replaced the call to open the Organisation form with exactly the same call but to open "TEST_Form" .
                  Result ... No nasty messages.

                  Conclusions:
                  The problem isn't in the code for EITHER of the forms involved.
                  Therefore the errant 'property' must be a property of the Organisation form or something on it, and must have been SET in design view.
                  But this is a bit of a paradox, as the only way to set a property in design view is to do it in the Properties window, and surely all the properties listed there are known to Access and would therefore be 'found' by it, even if I accidentally set one without noticing?

                  The next thing I'm going to do is make a completely new form (uurrgh), and copy the existing code into its module. I will let you know the outcome!

                  Comment

                  • nico5038
                    Recognized Expert Specialist
                    • Nov 2006
                    • 3080

                    #10
                    Just make sure you execute a "Compact and repair" after deleting the old form and before creating the new form.
                    Access can get corrupted when you re-create a deleted form with the same name....

                    Nic;o)

                    Comment

                    • julietbrown
                      New Member
                      • Jan 2010
                      • 99

                      #11
                      GOT RID OF IT!!! (The message, I mean, not the form!!)

                      The solution (as is) is not very satisfactory ... It's sort of behavioural therapy for Macros ... Like "Let's stop him wetting the bed, and not worry about why he's doing it"

                      I tracked the error to the embedded Save Macro and tried deleting the error reporting line of the macro. Sure enough it stopped whining about unfound properties. Since I was unable to discover ANYTHING it might winge about, and it's now all working perfectly, I think I'll just leave it like that. I do feel a bit of a frustrated detective, though.

                      Thanks for the tip about re-creating forms.

                      Comment

                      Working...