Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   "Invalid use of Property" (http://www.go4expert.com/forums/invalid-property-t28552/)

Donarco 9Jun2012 05:12

"Invalid use of Property"
 
Thread Title: "Invalid Use of Property"

I'm having difficulty with a very small routine and am listing code below:
Code:

 
  Dim OBplus As Double
  Dim sOBplus As String
  Dim OBNonPlus As Double
  Dim sOBNonPlus As String
 
  ' Accumulates to Variables OBPlus & OBNeg
  rsGlact.MoveFirst
  Do While rsGlact.EOF = False
    gAcno = rsGlact.Fields("Acno")
    If rsGlact.Fields("Rptype") = "P" Then
      If rsGlact.Fields("Oldbal") > 0 Then
        OBplus = (OBplus + rsGlact.Fields("Oldbal"))
      Else
        OBNeg = (OBNeg + rsGlact.Fields("Oldbal"))
      End If
    End If
    rsGlact.MoveNext
  Loop
 
  ' Determines Difference and stores Round()
  txtOBPlus = OBplus
  txtOBNeg = OBNeg
  txtDiffOld = (OBplus + OBNeg)
  txtDiffOld = Round(txtDiffOld, 2)
 
  Dim OBplus As Double
  Dim sOBplus As String
  Dim OBNeg As Double
  Dim sOBNeg As String
 
  rsGlact.MoveFirst
  Do While rsGlact.EOF = False
    gAcno = rsGlact.Fields("Acno")
    If rsGlact.Fields("Rptype") = "P" Then
      If rsGlact.Fields("Oldbal") > 0 Then
        OBplus = (OBplus + rsGlact.Fields("Oldbal"))
      Else
        OBNonPlus = (OBNonPlus + rsGlact.Fields("Oldbal"))
      End If
    End If
    rsGlact.MoveNext
  Loop
 
  ' Determines Difference and stores Round()
  txtOBPlus = OBplus
  txtOBNonPlus = OBNonPlus
  txtDiffOld = (OBplus + OBNonPlus)
  txtDiffOld = Round(txtDiffOld, 2)
   
  sOBplus = OBplus
  sOBNeg = OBNeg
 
  txtOBPlus = sOBplus
  txtOBNeg = sOBNeg

It's at this point that my problem occurs. When attempting to enter to frmUtility, I receive the following error: "Invald use of Property"

I will greatly appreciate help.

Don Gaither

Donarco 9Jun2012 05:25

"Invalid use of Property"
 
This is a correction of an earlier Post:

I'm having difficulty with a small routine, the code for which I'm listing below:
Code:


  Dim OBplus As Double
  Dim sOBplus As String
  Dim OBNonPlus As Double
  Dim sOBNonPlus As String
 
  rsGlact.MoveFirst
  Do While rsGlact.EOF = False
    gAcno = rsGlact.Fields("Acno")
    If rsGlact.Fields("Rptype") = "P" Then
      If rsGlact.Fields("Oldbal") > 0 Then
        OBplus = (OBplus + rsGlact.Fields("Oldbal"))
      Else
        OBNonPlus = (OBNonPlus + rsGlact.Fields("Oldbal"))
      End If
    End If
    rsGlact.MoveNext
  Loop
 
  ' Determines Difference and stores Round()
  txtOBPlus = OBplus
  txtOBNonPlus = OBNonPlus
  txtDiffOld = (OBplus + OBNonPlus)
  txtDiffOld = Round(txtDiffOld, 2)
 
 
  sOBplus = OBplus
  sOBNeg = OBNeg
 
  txtOBPlus = sOBplus
  txtOBNonPlus = sOBNeg

Its at this point that the error ("Invalid use of Preperty") occurs. I have written numerous similar routines with no problem.

I will greatly appreciate help in solving this problem.

DONARCO

jailbot 10Jun2012 17:13

Re: "Invalid use of Property"
 
Quote:

Originally Posted by Donarco (Post 95605)
This is a correction of an earlier Post:

I'm having difficulty with a small routine, the code for which I'm listing below:

Dim OBplus As Double
Dim sOBplus As String
Dim OBNonPlus As Double
Dim sOBNonPlus As String

rsGlact.MoveFirst
Do While rsGlact.EOF = False
gAcno = rsGlact.Fields("Acno")
If rsGlact.Fields("Rptype") = "P" Then
If rsGlact.Fields("Oldbal") > 0 Then
OBplus = (OBplus + rsGlact.Fields("Oldbal"))
Else
OBNonPlus = (OBNonPlus + rsGlact.Fields("Oldbal"))
End If
End If
rsGlact.MoveNext
Loop

' Determines Difference and stores Round()
txtOBPlus = OBplus
txtOBNonPlus = OBNonPlus
txtDiffOld = (OBplus + OBNonPlus)
txtDiffOld = Round(txtDiffOld, 2)


sOBplus = OBplus
sOBNeg = OBNeg

txtOBPlus = sOBplus
txtOBNonPlus = sOBNeg

Its at this point that the error ("Invalid use of Preperty") occurs. I have written numerous similar routines with no problem.

I will greatly appreciate help in solving this problem.

DONARCO


plz tell me where did you assign a value to OBneg????

shabbir 10Jun2012 17:37

Re: "Invalid use of Property"
 
I have merged your threads. For correction, you don't need a second thread.

pein87 11Jun2012 02:03

Re: "Invalid use of Property"
 
You have undeclared variables that your trying to assign values to. Check the last chunk of code so see where you dimensioned those variables.

Code: Vb

sOBNeg = OBNeg

txtOBPlus = sOBplus
txtOBNonPlus = sOBNeg


Your trying to use the MoveFirst property when I don't see where you gave reGlact an instance of a class. Do you use visual studio or visual basic express?

Donarco 22Jun2012 02:25

Re: "Invalid use of Property"
 
To Those Respondants:

I have used excerpts from multiple responses and my routine is now working just fine. Thanks very
much for your time and trouble.

donarco (Don Gaither)


All times are GMT +5.5. The time now is 04:28.