Results 1 to 13 of 13
  1. #1
    Lounger
    Join Date
    Feb 2003
    Location
    Clear Spring, Maryland, USA
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Method or Data Member not found (XP)

    I am trying to set the value of a field based on the selection in an option box. I am using the following code:

    Private Sub FamilyIDOptionBox_AfterUpdate()
    If (Me.FamilyIDOptionBox) = 1 Then
    Me.FamilyID = Me.FathersLastName + Me.FathersPhone
    Else
    Me.FamilyID = Me.MothersLastName + Me.MothersPhone
    End If
    End Sub

    But I get a "Method or Data member not found". What am I doing wrong?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Method or Data Member not found (XP)

    What are you actually trying to do here? The error you're getting usually means you've misspelled a control name or you're trying to do something that doesn't agree with the methods or properties of that object. If you look at the code when you get this error, it should have highlighted something, and that will tell you where it is having a problem.
    Charlotte

  3. #3
    Lounger
    Join Date
    Feb 2003
    Location
    Clear Spring, Maryland, USA
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Method or Data Member not found (XP)

    I am trying to allow someone to pick whose name and phone number fields will be used to compute the familyId (which will be the last name + phone number) from an option box. The only choices in the option box are: fathers or mothers. Fathers set the box to 1, Mothers to 2. I think I have checked the spelling of the controls, but in my code do I use the name of the control on the form or the field name in the query? And how do I distinquish between the two? "Me.FathersLastName" is the section that is highlighted in red. By the way, what does the Me. stand for.

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Method or Data Member not found (XP)

    I thought you had to use the ! and not the . character for use in identifying controls, your statement :
    Me.FamilyID = Me.FathersLastName + Me.FathersPhone
    should probably read:
    Me!FamilyID = Me!FathersLastName + Me!FathersPhone

    One more point, are you allowed to use the + and not the & for concatenation?

    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Method or Data Member not found (XP)

    Do you have a control called FathersLastName? Use the name of the control. If nothing else, it will keep you and your code from getting confused. The Me refers to the current container, which I assume is a form. So if you don't have a control called FathersLastName, then the error is telling you that it isn't finding that member of the form's controls collection.
    Charlotte

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Method or Data Member not found (XP)

    No, you don't. The bang (!) is rationalized into a dot (.) anyhow when the code is parsed. Using the dot allows you to use intellisense to find the control name instead of trying to remember it. The + sign can be used for concatenation but it sometimes gives unexpected results. If either side of the expression is null, the + operator will return a null for the whole expression, while the & won't. One problem with using the + for concatenation is that if you have a number involved, it may decide you're trying to do an arithmetic operation and throw a type mismatch error.
    Charlotte

  7. #7
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Method or Data Member not found (XP)

    Thanks for the explanation, obviously they have made it smarter than A97.

    So why would you use the + for concatenation when all those things can go wrong. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

    Pat

  8. #8
    Lounger
    Join Date
    Feb 2003
    Location
    Clear Spring, Maryland, USA
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Method or Data Member not found (XP)

    I have changed the code to:

    Private Sub FamilyIDOptionBox_AfterUpdate()
    If Me.FamilyIDOptionBox = 1 Then
    Me.FathersLastName Me.FathersPhone = Me.Family_ID
    Else
    Me.MothersLastName Me.MothersPhone = Me.Family_ID
    End If
    End Sub

    And now I am getting an "Invalid use of property" for the "Me.FathersPhone" part of the code. I tried using the ! instead of the . and that didn't seem to help.

  9. #9
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Method or Data Member not found (XP)

    Go back to the original way you were doing this, and just check if the names are control names and not recordsource names.
    What Charlotte said seems the most logical, ie. control names.
    If all this fails would you consider posting a zipped A2000 version of your database?
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  10. #10
    Lounger
    Join Date
    Feb 2003
    Location
    Clear Spring, Maryland, USA
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Method or Data Member not found (XP)

    I added one extra field (FamilyCode) and used the following code and it finally worked.

    If (Me.FamilyIDOptionBox) = 1 Then
    Me.FamilyCode = Me.FathersLastName & Me.FathersPhone
    Else
    Me.FamilyCode = Me.MothersLastName & Me.MothersPhone
    End If

    I'm still not completely sure why some of the other things I tried didn't work, but it does now. Thanks again for all your help!

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Method or Data Member not found (XP)

    So how are you populating FamilyID, or did you take that out?
    Charlotte

  12. #12
    Lounger
    Join Date
    Feb 2003
    Location
    Clear Spring, Maryland, USA
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Method or Data Member not found (XP)

    I basically took that out and replaced it with FamilyCode, altough as far as I can tell, they both were doing the same thing. I just couldn't get the code to work the way I was doing it.

  13. #13
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Method or Data Member not found (XP)

    Just a general comment about this sort of thing. We've found you are better off using a numeric value for these kinds of things. For one, you can pretty much ensure that it is unique by making it an autonumber, and performance is typically better because indexes on numeric fields are more efficient than those on text fields.

    In a church system I developed, after much debate back and forth, we adopted a single table for both families and individuals. We used a flags to determine whether a given record was a person, a family or both. We then used a linking table to identify the various relationships between individuals and families - i.e. husband, wife, son, daughter, etc. It actually turned out to work pretty well, and we were able to use a treeview control to display family information quite efficiently. Not sure this is of value to you at this stage, but wanted to share it for what it's worth.
    Wendell

Posting Permissions

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