"Invalid use of Property"

Donarco's Avatar
Light Poster
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

Last edited by shabbir; 10Jun2012 at 17:32.. Reason: Code blocks
0
Donarco's Avatar
Light Poster
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

Last edited by shabbir; 10Jun2012 at 17:31.. Reason: Code blocks
0
jailbot's Avatar, Join Date: Jun 2012
Newbie Member
Quote:
Originally Posted by Donarco View Post
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????
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
I have merged your threads. For correction, you don't need a second thread.
0
pein87's Avatar
Ambitious contributor
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?
0
Donarco's Avatar
Light Poster
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)