Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / July 2006



Tip: Looking for answers? Try searching our database.

Invalid Use of Property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
badgerduke@gmail.com - 28 Jul 2006 21:50 GMT
I am struggling with a piece of code which leads to the error described
in the title of thiis message.  The code stops at "Public Function
TestRockDescriptionForUniqueness() As Boolean" in the second function
listed.   Anybody see a mistake(s)?

Duke

Private Function ValidData() As Boolean
   Dim strMessage As String
   If txtNewGemName = "" Then
       txtNewGemName.SetFocus
       strMessage = "You must enter the name of the new gem."
       ValidData = False
   Else
      If Not TestRockDescriptionForUniqueness Then
           ValidData = False
           MsgBox "The Add New Gem value is already taken",
vbExclamation, "Duplicate gem name"
      Else
           ValidData = True
       End If
   End If
End Function
=====
Public Function TestRockDescriptionForUniqueness() As Boolean
   Dim rs As Recordset
   Set rs = New Recordset
   rs = FindRockCodeTable
   TestRockDescriptionForUniqueness = True
   With rs
       Do Until .EOF
           If !RockDescription = txtAddNewGem Then
               TestRockDescriptionForUniqueness = False
           End If
       Loop
End Function

=========

Public Function FindRockCodeTable() As Recordset
   Set rsRockCodeTable = New Recordset
   rsRockCodeTable.Open "SELECT GemID, GemDesciption FROM RockCode"
   FindRockCodeTable = rsRockCodeTable
End Function
Henning - 29 Jul 2006 00:48 GMT
> I am struggling with a piece of code which leads to the error described
> in the title of thiis message.  The code stops at "Public Function
[quoted text clipped - 28 lines]
>         Do Until .EOF
>             If !RockDescription = txtAddNewGem Then
Where is RockDescription defined? Or should it be GemDesciption?
>                 TestRockDescriptionForUniqueness = False
>             End If
>         Loop
Missing End With
> End Function
>
[quoted text clipped - 5 lines]
>     FindRockCodeTable = rsRockCodeTable
> End Function

Add Option Explicit at the very top of Forms and Modules to reduce spelling
errors.

/Henning
Henning - 29 Jul 2006 01:26 GMT
> I am struggling with a piece of code which leads to the error described
> in the title of thiis message.  The code stops at "Public Function
[quoted text clipped - 40 lines]
>     FindRockCodeTable = rsRockCodeTable
> End Function

Also, this can't be all the code. So it's hard to point out any more errors.
How do you connect to and open the database?
I would move the connection and the query in FindRockCode() to
TestRockDescriptionForUniqueness().
Recordset is never closed.

/Henning
Steve Gerrard - 29 Jul 2006 02:36 GMT
>I am struggling with a piece of code which leads to the error described
> in the title of thiis message.  The code stops at "Public Function
> TestRockDescriptionForUniqueness() As Boolean" in the second function
> listed.   Anybody see a mistake(s)?

>    rs = FindRockCodeTable
needs to be
   Set rs = FindRockCodeTable

also
>    Set rs = New Recordset
serves no purpose there.

Similarly,
>    FindRockCodeTable = rsRockCodeTable
needs to be
   Set FindRockCodeTable = rsRockCodeTable

Finally,
>    rsRockCodeTable.Open "SELECT GemID, GemDesciption FROM RockCode"

is unlikely to  work since no connection to any database is specified.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.