"Invalid use of Property"

Light Poster
9Jun2012,05:12   #1
Donarco's Avatar
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
Light Poster
9Jun2012,05:25   #2
Donarco's Avatar
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
Newbie Member
10Jun2012,17:13   #3
jailbot's Avatar
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????
Go4Expert Founder
10Jun2012,17:37   #4
shabbir's Avatar
I have merged your threads. For correction, you don't need a second thread.
Ambitious contributor
11Jun2012,02:03   #5
pein87's Avatar
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?
Light Poster
22Jun2012,02:25   #6
Donarco's Avatar
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)