Results 1 to 5 of 5
  1. #1
    virgilio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    66

    Adding new field to table. Method or Data Member Not Found

    I am working on an established database and I would like to add a new field to one of the main tables. I added the field, I saved the field, I verified that it is present, I verified the spelling. When I try to access the new field from my code I get:



    Code:
    Compile Error: Method or Data Member Not Found
    What can I do?

    EDIT: Also, just noticed that my 'Properties' box is empty in the VBA window when this error is raised, so no record source is visible. Did I somehow get to this function with the record source being unset?

    Here are the relevant parts of my code:

    Code:
    Private Sub Form_Open(Cancel As Integer)
       If Nz(Me.OpenArgs) = 0 Then
          Me.RecordSource = "LOT_DATES"
          DoCmd.RunCommand acCmdRecordsGoToNew
          GoTo endMe
       Else
          ' I'm passing open arguments, so this is my record source
          Me.RecordSource = "Select LOT_DATES.* FROM LOT_DATES WHERE (((LOT_DATES.LOT_NUMBER)='" & Me.OpenArgs & "'));"
       End If
    .
    .
    .
    endMe:
       Call updateTally
    and

    Code:
    Private Function updateTally()
    
    
       Dim requiredTally
       Dim completedTally
    
       requiredTally = 0
       completedTally = 0
    
    .
    .
    .
    
    
       If requiredTally = completedTally Then
          Me.TST_COMP = Now()
       Else
          Me.TST_COMP = Null
       End If
    My new field is TST_COMP and that is what raises the error

  2. #2
    virgilio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    66
    So I fixed this issue by changing the IF statement to:

    Code:
       If requiredTally = completedTally Then
          Me!TST_COMP = Now()
       Else
          Me!TST_COMP = Null
       End If
    But I tried it earlier and it didnt' work, not sure what changed between then and now. Also, I'm altering fields in my record source using a 'period' instead of 'exclamation point' in a LOT of places without generating an error. Why would it work elsewhere but not here?

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    7,330
    Hmm, some confusing stuff there for someone who's not the designer, like
    - passing a string as criteria to a field with the word "number" in its name.
    - or the use of Null: IIRC it returns a zls ("") if you don't provide the 'valueIfNull' parameter, thus you'd be comparing "" to 0.
    - why GoTo endMe when you're going to go there anyway when you exit the IF block?
    - in the update function you make 2 variables = 0 then check to see if they're 0??

    To attempt to answer your last question - I'm guessing you don't have Option Explicit turned on (or at least it's missing from this module) so you might be getting away with ! vs dot. A second indicator of that is that you don't declare TST_COMP in your procedure, which if the code works at all, it's another variant variable. ! provides late bound access to the default member of an object, passing what follows ! as a string value to that member. It means a couple of things to you:
    a) you cannot use Intellisense for that object
    b) because the object is accessed at run time (late bound) it will raise an error if you've misspelled it's name. I believe it should raise an error if it has not been declared, but am not 100% sure of that because i) I enforce declaration with Option Explicit, and ii) almost never use ! syntax.
    c) if you compile your code, it will not catch name errors where the object is preceded with !
    d) if you have condition b or c, you will not be able to turn this db into an accde.
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    "Everyone has a photographic memory; some just don't have film." Steven Wright

  4. #4
    virgilio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    66
    Quote Originally Posted by Micron View Post
    Hmm, some confusing stuff there for someone who's not the designer, like
    - passing a string as criteria to a field with the word "number" in its name.
    - or the use of Null: IIRC it returns a zls ("") if you don't provide the 'valueIfNull' parameter, thus you'd be comparing "" to 0.
    - why GoTo endMe when you're going to go there anyway when you exit the IF block?
    - in the update function you make 2 variables = 0 then check to see if they're 0??

    To attempt to answer your last question - I'm guessing you don't have Option Explicit turned on (or at least it's missing from this module) so you might be getting away with ! vs dot. A second indicator of that is that you don't declare TST_COMP in your procedure, which if the code works at all, it's another variant variable. ! provides late bound access to the default member of an object, passing what follows ! as a string value to that member. It means a couple of things to you:
    a) you cannot use Intellisense for that object
    b) because the object is accessed at run time (late bound) it will raise an error if you've misspelled it's name. I believe it should raise an error if it has not been declared, but am not 100% sure of that because i) I enforce declaration with Option Explicit, and ii) almost never use ! syntax.
    c) if you compile your code, it will not catch name errors where the object is preceded with !
    d) if you have condition b or c, you will not be able to turn this db into an accde.
    - passing a string as criteria to a field with the word "number" in its name.

    True, I never thought of how confusing that might be to the next maintainer.

    - or the use of Null: IIRC it returns a zls ("") if you don't provide the 'valueIfNull' parameter, thus you'd be comparing "" to 0.
    - why GoTo endMe when you're going to go there anyway when you exit the IF block?
    - in the update function you make 2 variables = 0 then check to see if they're 0??


    I left a lot of irrelevant code out, I tried to indicate that with the vertical (...). Those points are all answered in the missing code.

    You're right about me having Option Explicit off. When I built this, I couldn't get it to run with it on so I turned it off, and I guess I hamstrung myself a bit. Now that I'm more experienced with VBA, maybe my next project will be to turn it on and debug!

    Thank you for pointing me in the right direction!

    EDIT1: PS, Does zls mean Zero Length String?

    EDIT2: Correction: I have Option Explicit On on this form, (Its off elsewhere). I guess that wasn't the answer.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    7,330
    EDIT1: PS, Does zls mean Zero Length String?
    yes
    EDIT2: Correction: I have Option Explicit On on this form, (Its off elsewhere). I guess that wasn't the answer.
    suggest you add it everywhere, turn on the option (vb editor) and fix whatever issues arise as a result. If you had issues with it, then you had coding errors that you should not have ignored.
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    "Everyone has a photographic memory; some just don't have film." Steven Wright

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

Similar Threads

  1. Method or data member not found
    By annmv888 in forum Access
    Replies: 1
    Last Post: 12-17-2016, 08:36 PM
  2. Me.DOExp - Method or data member not found
    By GraeagleBill in forum Forms
    Replies: 4
    Last Post: 02-12-2016, 07:16 PM
  3. Method or data member not found
    By hendrikbez in forum Access
    Replies: 2
    Last Post: 11-21-2014, 10:52 AM
  4. Method or Data Member not found
    By johnnyBQue in forum Programming
    Replies: 4
    Last Post: 11-03-2014, 07:15 AM
  5. Method or data member not found
    By papa yaw in forum Programming
    Replies: 5
    Last Post: 12-17-2012, 02:19 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 - Senior Forums