Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Report Coding - Part II

Status
Not open for further replies.

MichaelF81

Programmer
Sep 20, 2005
178
US
I have some VBA code that does some checks for me and fill in a text box.

Code:
If Not IsNull(Me.Text71a) Then
Dim v1, v2 As Integer
v1 = Me.Text71
v2 = Me.Text71a
  If v1 < v2 Then
   Me.lblCalc.Value = CInt(Round(v1, 0))
  Else
   Me.lblCalc.Value = CInt(Round(v2, 0))
  End If
Else
Me.lblCalc.Value = ""
End If

I now need to take the value from
Code:
Me.SquareFeet
and divide it by
Code:
Me.lblCalc
and get the sum of the whol thing placed into
Code:
Me.Text106

lblCalc is a text field, we didn't change the name, but we changed what it is.

Code:
Dim vS As Integer
Dim vT As String

vT = CInt(Me.lblCalc)
vS = Me.SquareFeet

Me.lblText106 = Sum(vS / vT)

Ideas?




"Adults are just obsolete children and the hell with them." - Dr. Seuss
 
Hi Michael,

In the 'control source' property of lbText106 use this:

=SquareFeet / CInt(lblCalc


ATB

Darrylle


Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
Sorry,

=SquareFeet / CInt(lblCalc)

Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
This does not work. It asks for the value of lblCalc, the value is retrieved from the VB code, prior to that it is null.




"Adults are just obsolete children and the hell with them." - Dr. Seuss
 
Hi Mike,

OK - you might have to clarify exactly where and when these calculations occur. Try this in the meantime:

=if(not isnull(lblCalc), "SquareFeet / CInt(lblCalc)","")

... which checks if lblCalc has a value before populating itself.

ATB

Darrylle



Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
Code:
=IIf(Not IsNull([lblCalc]),[SquareFeet]/CInt([lblCalc]),"")

This works, but now how do I get it to sum
Code:
[SquareFeet]/CInt([lblCalc])
?




"Adults are just obsolete children and the hell with them." - Dr. Seuss
 
Michael,

Sorry - place

=if(not isnull(lblCalc), "SquareFeet / CInt(lblCalc)","")

in control source of lblText106.


atb

Darrylle





Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
i did put it there... Also it has to be iif, not if.

How do I get the sum to work?

Code:
=if(not isnull(lblCalc), Sum([SquareFeet] / CInt([lblCalc])),"")

the above code does not work :(




"Adults are just obsolete children and the hell with them." - Dr. Seuss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top