|
-
Feb 9th, 2006, 11:27 PM
#1
Thread Starter
Hyperactive Member
[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:
Option Explicit
Private cn As ADODB.Connection
Private rs As ADODB.Recordset
Private total4
Dim temp, mov
Dim DataMember As String
Dim Data As Object
Private Sub Form_Load()
Set cn = New ADODB.Connection
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open App.Path & "./Car Rental.mdb"
Set rs = New ADODB.Recordset
rs.Open "Customer", cn, adOpenStatic, adLockOptimistic, _
adCmdTable
Set Text1.DataSource = rs
Text1.DataField = "CustID"
Set Text2.DataSource = rs
Text2.DataField = "CustFname"
Set Text3.DataSource = rs
Text3.DataField = "CustLname"
Call GetDataMember
d.Caption = rs.total4 '<------- error source
End Sub
Private Sub GetDataMember()
Set Data = rs
temp = rs.RecordCount
If temp < 2 Then
mov = temp & " Customer "
Else
mov = temp & " Customers "
End If
total4 = "Total " & mov & "in the database."
End Sub
-
Feb 9th, 2006, 11:42 PM
#2
Fanatic Member
Re: Method or data menber not found
these codes are in one form??
-
Feb 9th, 2006, 11:56 PM
#3
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:
d.Caption = rs.Fields("total4")
-
Feb 9th, 2006, 11:58 PM
#4
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/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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 10th, 2006, 12:00 AM
#5
Lively Member
Re: Method or data menber not found
i'll also try
VB Code:
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....
-
Feb 10th, 2006, 12:08 AM
#6
Thread Starter
Hyperactive Member
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:
d.Caption = rs!total4 '<---- error
-
Feb 10th, 2006, 12:11 AM
#7
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 10th, 2006, 12:13 AM
#8
Lively Member
Re: Method or data menber not found
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....
-
Feb 10th, 2006, 12:15 AM
#9
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:
Private total4
'...
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 10th, 2006, 12:16 AM
#10
Thread Starter
Hyperactive Member
Re: Method or data menber not found
total4 is used to calculate recordcount of my records.
It just a name.
VB Code:
Private Sub GetDataMember()
Set Data = rs
temp = rs.RecordCount
If temp < 2 Then
mov = temp & " Customer "
Else
mov = temp & " Customers "
End If
total4 = "Total " & mov & "in the database."
End Sub
-
Feb 10th, 2006, 12:17 AM
#11
Thread Starter
Hyperactive Member
Re: Method or data menber not found
 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:
Private total4
'...
total4 = "Total " & mov & "in the database."
then what should i do?
-
Feb 10th, 2006, 12:17 AM
#12
Lively Member
Re: Method or data menber not found
maybe this one might work
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....
-
Feb 10th, 2006, 12:17 AM
#13
Re: Method or data menber not found
Then it should be something like...
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 10th, 2006, 12:19 AM
#14
Thread Starter
Hyperactive Member
Re: Method or data menber not found
 Originally Posted by RobDog888
Then it should be something like...
That is the same as my original coding.
See thread 1 pls.
-
Feb 10th, 2006, 12:20 AM
#15
Re: Method or data menber not found
No its not. Check where it says "Error here"
VB Code:
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 10th, 2006, 12:23 AM
#16
Thread Starter
Hyperactive Member
Re: Method or data menber not found
Thanks all your inputs, i got the error solved.
VB Code:
rs.Open "Customer", cn, adOpenStatic, adLockOptimistic, _
adCmdTable
VB Code:
rs.Open "Customer", cn, adOpenStatic, adLockOptimistic, adCmdTable
Is there a difference when you do the 2 coding above?
-
Feb 10th, 2006, 12:24 AM
#17
Lively Member
Re: Method or data menber not found
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....
-
Feb 10th, 2006, 12:24 AM
#18
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|