Results 1 to 18 of 18

Thread: [RESOLVED] Method or data menber not found

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Resolved [RESOLVED] Method or data menber not found

    Compile error:Method or data menber not found.
    Any ideas what's wrong with this coding?

    VB Code:
    1. Option Explicit
    2. Private cn As ADODB.Connection
    3. Private rs As ADODB.Recordset
    4. Private total4
    5. Dim temp, mov
    6. Dim DataMember As String
    7. Dim Data As Object
    8.  
    9.  
    10. Private Sub Form_Load()
    11. Set cn = New ADODB.Connection
    12. cn.Provider = "Microsoft.Jet.OLEDB.4.0"
    13. cn.Open App.Path & "./Car Rental.mdb"
    14.  
    15. Set rs = New ADODB.Recordset
    16. rs.Open "Customer", cn, adOpenStatic, adLockOptimistic, _
    17. adCmdTable
    18.  
    19. Set Text1.DataSource = rs
    20. Text1.DataField = "CustID"
    21. Set Text2.DataSource = rs
    22. Text2.DataField = "CustFname"
    23. Set Text3.DataSource = rs
    24. Text3.DataField = "CustLname"
    25.  
    26. Call GetDataMember
    27. d.Caption = rs.total4 '<------- error source
    28.  
    29. End Sub
    30. Private Sub GetDataMember()
    31.  
    32. Set Data = rs
    33. temp = rs.RecordCount
    34.  
    35. If temp < 2 Then
    36.  mov = temp & " Customer "
    37. Else
    38.  mov = temp & " Customers "
    39. End If
    40.  
    41. total4 = "Total " & mov & "in the database."
    42.  
    43. End Sub

  2. #2
    Fanatic Member noielen's Avatar
    Join Date
    Nov 2005
    Location
    Cebu, Phil.
    Posts
    680

    Re: Method or data menber not found

    these codes are in one form??

  3. #3
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Method or data menber not found

    total4 is not a member of rs, if it's a field in your table then try..
    VB Code:
    1. d.Caption = rs.Fields("total4")

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Method or data menber not found

    Yes, you probably mixed up the short hand notation of using a period when it shold be an exclamation point.
    VB Code:
    1. d.Caption = rs!total4
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Lively Member
    Join Date
    Aug 2004
    Location
    Philippines
    Posts
    117

    Re: Method or data menber not found

    i'll also try

    VB Code:
    1. d.Caption = rs.Fields(total4)
    Ask a question and you're a fool for three minutes; do not ask a question and you're a fool for the rest of your life. (Chinese Proverb)

    ^ _ ^

    hope to earn reputation soon....

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Re: Method or data menber not found

    Sorry, i got an runtime error.

    Item cannot be found in the collection corresponding to the requested name or ordinal.

    VB Code:
    1. d.Caption = rs!total4 '<---- error

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Method or data menber not found

    Then total4 is not a field in your table or query select statement. Verify the spelling in your base table.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    Lively Member
    Join Date
    Aug 2004
    Location
    Philippines
    Posts
    117

    Re: Method or data menber not found

    what is total4?

    VB Code:
    1. d.Caption = total4
    Ask a question and you're a fool for three minutes; do not ask a question and you're a fool for the rest of your life. (Chinese Proverb)

    ^ _ ^

    hope to earn reputation soon....

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Method or data menber not found

    Doh! Its a variant variable and not a field name at all. Your setting a string to it and that string is not in your database' fields collection for your base table.
    VB Code:
    1. Private total4
    2.  
    3. '...
    4. total4 = "Total " & mov & "in the database."
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Re: Method or data menber not found

    total4 is used to calculate recordcount of my records.
    It just a name.

    VB Code:
    1. Private total4

    VB Code:
    1. Private Sub GetDataMember()
    2.  
    3. Set Data = rs
    4. temp = rs.RecordCount
    5.  
    6. If temp < 2 Then
    7.  mov = temp & " Customer "
    8. Else
    9.  mov = temp & " Customers "
    10. End If
    11.  
    12. total4 = "Total " & mov & "in the database."
    13.  
    14. End Sub

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Re: Method or data menber not found

    Quote Originally Posted by RobDog888
    Doh! Its a variant variable and not a field name at all. Your setting a string to it and that string is not in your database' fields collection for your base table.
    VB Code:
    1. Private total4
    2.  
    3. '...
    4. total4 = "Total " & mov & "in the database."
    then what should i do?

  12. #12
    Lively Member
    Join Date
    Aug 2004
    Location
    Philippines
    Posts
    117

    Re: Method or data menber not found

    maybe this one might work

    VB Code:
    1. d.Caption = total4
    Ask a question and you're a fool for three minutes; do not ask a question and you're a fool for the rest of your life. (Chinese Proverb)

    ^ _ ^

    hope to earn reputation soon....

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Method or data menber not found

    Then it should be something like...
    VB Code:
    1. d.Caption = total4
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Re: Method or data menber not found

    Quote Originally Posted by RobDog888
    Then it should be something like...
    VB Code:
    1. d.Caption = total4
    That is the same as my original coding.
    See thread 1 pls.

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Method or data menber not found

    No its not. Check where it says "Error here"
    VB Code:
    1. d.Caption = [color=red][b]rs.[/b][/color]total4 '<------- error source
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Re: Method or data menber not found

    Thanks all your inputs, i got the error solved.

    VB Code:
    1. rs.Open "Customer", cn, adOpenStatic, adLockOptimistic, _
    2. adCmdTable

    VB Code:
    1. rs.Open "Customer", cn, adOpenStatic, adLockOptimistic, adCmdTable

    Is there a difference when you do the 2 coding above?

  17. #17
    Lively Member
    Join Date
    Aug 2004
    Location
    Philippines
    Posts
    117

    Re: Method or data menber not found

    none
    Ask a question and you're a fool for three minutes; do not ask a question and you're a fool for the rest of your life. (Chinese Proverb)

    ^ _ ^

    hope to earn reputation soon....

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Method or data menber not found

    That will not create the error as its nothing more then a line continuation character. Also, if it was it would have highlighted that line instead.

    As long as its working now.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width